Overview
Start new Cloudflare static sites on Workers with static assets; Cloudflare’s docs say to start new projects on Workers and keep Pages for existing ones. A Worker with an assets.directory serves the build output, and Workers Builds redeploys on every push. Pages is not deprecated, so the Pages settings are listed at the end for projects already on it.
Prerequisites
- A Cloudflare account and a GitHub repo containing the site. For Quartz 4, clone
-b v4and set up the repo as in steps 1 and 2 of deploy-quartz-site; it builds withnpx quartz buildtopublic/. - Node pinned for the build: add a
.node-versionor.nvmrcfile, or set aNODE_VERSIONbuild variable. - A domain whose DNS is on Cloudflare (needed for Custom Domains on a Worker).
Steps
1. Add wrangler.jsonc at the repo root
{
"name": "my-site",
"compatibility_date": "2026-10-01",
"assets": { "directory": "./public" }
}The name must match the Worker name in the dashboard, or the build fails. For a Quartz site, set baseUrl to the production domain in quartz.config.ts; Plugin.CNAME() is only for GitHub Pages and can stay or go.
2. Connect the repo with Workers Builds
In the dashboard open Workers & Pages, create a Worker from a Git repository, and set:
- Build command:
npx quartz build - Deploy command:
npx wrangler deploy(the default)
Quartz reads git history for dates, and CI clones can be shallow; if dates collapse to the build date, make the build command git fetch --unshallow && npx quartz build.
3. Add the custom domain
On the Worker, open Settings, Domains & Routes, Add, Custom Domain. Cloudflare issues the certificate. A hostname that already has a CNAME record cannot become a Custom Domain, so delete the old record first. In code, the equivalent is:
{ "routes": [{ "pattern": "yourdomain.com", "custom_domain": true }] }4. Existing Pages projects
Settings for Pages: Framework preset None, build command npx quartz build, output directory public, production branch main, plus NODE_VERSION or a .node-version file. See Cloudflare’s “migrate from Pages to Workers” guide to move: pages_build_output_dir becomes assets.directory, and wrangler pages deploy becomes wrangler deploy.
Verify it worked
curl -sI https://yourdomain.com | head -1 # HTTP/2 200
curl -sI https://yourdomain.com | grep -i '^cf-ray' # served through CloudflareCommon errors
- Build fails on Node version. Pin it with
.node-versionorNODE_VERSION; the default differs between Workers Builds and Pages build images. - 404 for unknown URLs shows the wrong page. Set
assets.not_found_handlingto"404-page"(serves404.html) or"single-page-application"(servesindex.htmlwith 200). - Build fails with a name mismatch. The
nameinwrangler.jsoncdiffers from the Worker’s name in the dashboard. - Links point at the wrong host.
baseUrlstill holds the old domain; fix it and rebuild.
FAQ
Should I use Cloudflare Pages or Workers for a new static site?
Use Workers with static assets. Cloudflare’s docs say to start new projects on Workers and keep Pages for existing ones; Pages is not deprecated.
Why does my Workers build fail with a name mismatch?
The name in wrangler.jsonc differs from the Worker’s name in the dashboard; make them match.
Why can I not add my hostname as a Custom Domain?
A hostname that already has a CNAME record cannot become a Custom Domain, so delete the old record first.
Why do my Quartz page dates all show the build date on Cloudflare?
Quartz reads git history for dates and CI clones can be shallow; make the build command git fetch --unshallow && npx quartz build.
How do I move an existing site from Pages to Workers?
Follow Cloudflare’s “migrate from Pages to Workers” guide: pages_build_output_dir becomes assets.directory, and wrangler pages deploy becomes wrangler deploy.