Cloudflare Workers provides a serverless execution environment that lets you run applications at the edge without configuring or maintaining infrastructure. Workers Sites lets you serve static assets (HTML, CSS, JS) from KV storage, which is ideal for static sites.
This guide uses Hugo to generate the static files. Hugo is a fast static site generator written in Go that turns Markdown (and other content) into static HTML. You can use any static generator; the steps are the same once you have a build output directory.
Prerequisites
- Node.js and npm (for Wrangler).
- A Hugo site (or any static site) with a build output directory (e.g.
public/for Hugo). - A Cloudflare account (free tier is enough).
Install the Workers CLI (Wrangler)
Workers Sites require Wrangler, the Cloudflare Workers CLI. Install it globally and keep it up to date:
| |
See the Wrangler installation docs for other install options (e.g. standalone binary).
Generate your static site
Build your Hugo site so the output directory (e.g. public/) is ready to upload:
| |
Use whatever build command your static generator provides; the important part is having a folder of static files (e.g. public/).
Log in and create a Workers Site project
Log in to Cloudflare (this opens a browser to authenticate):
| |
Create a new Workers Site project. This creates wrangler.toml and a workers-site directory:
| |
Replace citizix with your project name if you prefer.
Configure wrangler.toml
Edit wrangler.toml and set the bucket to your site’s build directory:
| |
Add your account_id to wrangler.toml. You can find it in the Cloudflare dashboard under Workers & Pages (or the Workers/Overview section) in the right sidebar—you may need to scroll down.
Preview locally
Preview your site before deploying:
| |
This serves your static site locally so you can confirm everything looks correct.
Publish your site
Choose where to publish:
- workers.dev subdomain – Free
*.workers.devURL. Default: setworkers_dev = trueinwrangler.toml(or leave it unset). - Custom domain – A domain you’ve added to Cloudflare. Add your zone_id and a route in
wrangler.toml.
Custom domain example:
| |
Find zone_id in the Cloudflare dashboard under your domain → Overview (right sidebar).
Then deploy:
| |
Your static site will be live on your workers.dev URL or your custom domain.
Summary
You installed Wrangler, built a Hugo (or other) static site, configured wrangler.toml with your build directory and account (and optionally zone/route), and deployed with wrangler deploy. For more, see Cloudflare Workers Sites and Hugo’s documentation.