cfsite

Static sites on Cloudflare

How the klaska.net sites are hosted, previewed and checked. This site is built exactly that way, so everything described here is running underneath this page.

It is also the starting point for a new site: copy the repository, change a few names (New site) and the whole setup comes with it.

Principles

  1. Static files only. An assets-only Cloudflare Worker serves a folder of files. No server code, and no build step unless the site needs a generator.
  2. One site, one hostname. Each site lives on its own subdomain as a Worker custom domain. Production exists nowhere else.
  3. Every change goes through a pull request with a live preview, a comment with its links, a QR code for phones and Lighthouse scores.
  4. Production is the baseline. Visual regression compares the preview with the live site, so there are no stored screenshots to maintain.
  5. Pinned, so it behaves the same next year. Exact versions of every tool, a committed package-lock.json and a fixed compatibility date.
  6. Least privilege. Each repository has its own Cloudflare token that can only deploy Workers, and it expires after a year.
  7. Nothing left behind. Previews are deleted when the pull request closes, and outdated comments are collapsed.
  8. The documentation lives with the code. README and CLAUDE.md in every repository; here, the site itself.

Where each feature is in this repository

FeatureFile
Assets-only Worker on a custom domain wrangler.jsonc
Custom 404 page site/404.html
Redirects site/_redirects
Pinned tooling package.json
Per-repository deploy token scripts/create-deploy-token.sh
Production deploy, manual deploy button .github/workflows/deploy.yml
Previews, PR comment, QR code, cleanup
Visual regression, Lighthouse
Lighthouse job summary .github/lighthouse-summary.jq
Screenshot comparison tests/visual.spec.mjs
Link checker .github/workflows/link-checker.yml
Claude code review .github/workflows/claude-code-review.yml
Docs in the repository README.md, CLAUDE.md

Try it: /new is a redirect to the New site page, and a missing page shows the custom 404.