New static sites on Cloudflare: use Workers, not Pages
Problem: I wanted to host this site (static Astro build) on Cloudflare, and my first thought was Cloudflare Pages.
Why: Cloudflare now recommends Workers with Static Assets for every new project: static sites, SPAs and full-stack apps. Workers can do everything Pages can. Pages is still supported, but it’s no longer where a new project should start.
Fix: A static site needs no Worker code at all, only a wrangler.jsonc:
{
"name": "hefeng-dev",
"compatibility_date": "2026-10-01",
"assets": {
"directory": "./dist",
"not_found_handling": "404-page"
},
"routes": [{ "pattern": "hefeng.dev", "custom_domain": true }]
}
not_found_handling: "404-page"serves the nearest404.htmlwith a real 404 status.custom_domain: truemakeswrangler deploycreate the DNS record and certificate for the domain, as long as the domain is in the same Cloudflare account.- Deploy with
npm run build && npx wrangler deploy. Connect the GitHub repo under the Worker’s Settings → Builds so every push deploys. - If the new repo doesn’t show up in the Connect dialog: the Cloudflare GitHub App only sees the repos it was granted. Add the repo at github.com/settings/installations → Cloudflare Workers and Pages → Configure, signed in as the repo owner.
Remember: New site on Cloudflare → Workers + Static Assets. Pages only for projects that already live there.