I recently migrated my blog from Jekyll to Hugo — more on that soon. As part of the migration, I needed to set up deployments to Cloudflare. I typically use Cloudflare Pages, but when I went to configure it, I was met with a notice recommending Cloudflare Workers for new projects.
While Cloudflare hasn’t explicitly stated the future of Pages, it’s clear that the focus and innovation are shifting toward Workers.
In this post, I’ll walk you through how to set up your Hugo site for deployment using Cloudflare Workers.
Add Worker Files to Your Repository
To enable deployment, you’ll need to add a wrangler.jsonc
file. This configuration file tells Cloudflare how to build and serve your site correctly.
1{
2 "name": "example-com",
3 "compatibility_date": "2025-07-20",
4 "assets": {
5 "directory": "./public",
6 "html_handling": "auto-trailing-slash",
7 "not_found_handling": "404-page",
8 "run_worker_first": false
9 },
10 "build": {
11 "command": "hugo build --gc --minify",
12 },
13 "workers_dev": true,
14 "preview_urls": true
15}
Note: Replace the name value with your own domain or project name.
Commit the files to your Git repro.
Set Up Cloudflare Worker
Next, configure your Cloudflare Worker to deploy the site:
- Open your Cloudflare Dashboard
- Navigate to Compute (Workers) → Workers & Pages
- Click Get Started under Import a Repository
- Select Connect to Git and link your GitHub account if prompted
- Choose the repository you committed the files to
- Enter a Project name of your choice
- Leave the remaining settings at their defaults and click Create and Deploy
Cloudflare will now build and deploy your website. After a few minutes, you can preview it at the automatically generated *.workers.dev URL.
Custom Domain
The default *.workers.dev URL isn’t ideal for branding or memorability, so let’s add your own custom domain:
- Open your Worker project and navigate to the Settings tab
- Under Domains & Routes, click + Add
- Select Custom domain
- Enter your domain name (e.g. example.com)
- Click Add domain to complete the setup
Cloudflare will setup your domain and configure the DNS. It might take a few minutes before the domain name works.
By combining Hugo and Cloudflare Workers, you now have a fast, reliable, and customizable static site deployment pipeline.
This setup is lightweight, scalable, and gives you the flexibility to integrate more advanced CI/CD practices in the future.
Happy building!