tyco
1
Following a discussion on hosting Hugo on a Cloudflare worker, @jmooring came up with an excellent solution.
Here’s an example project hosted on a Cloudflare Worker:
This is the build script:
And the wrangler.toml file
Those are the only two files you need to copy to your project and configure to your liking. For example–
- change Dart SASS version or if you don’t transpile SASS to CSS, you can remove Dart SASS code from the
build.sh
file.
- change the time zone.
- change Hugo version
I was able to get the deployment working without a custom build script by using the following simplified wrangler.jsonc
configuration:
{
"name": "example-com",
"compatibility_date": "2025-07-20",
"assets": {
"directory": "./public",
"html_handling": "auto-trailing-slash",
"not_found_handling": "404-page",
"run_worker_first": false
},
"build": {
"command": "hugo build --gc --minify",
},
"workers_dev": true,
"preview_urls": true
}
Not sure it will work for every environment as I have mine themes defined in go modules
tyco
3
This example is shared by a Hugo support/maintainer person. So, for a user, it is the way I would recommend to go with.
The build script:
- Installs a specific version of Hugo
- Installs a specific version of Dart Sass to transpile Sass to CSS
- Sets the system timezone
- Ensures that
Page.GitInfo
returns the expected results
- Addresses https://github.com/gohugoio/hugo/issues/9810
In my view all but #2 are required for every site.