Cloudflare Pages serves a repository from its edge network. A StaticScope build needs no build command, no framework and no server: Cloudflare copies the branch and serves the files.
The GitHub add-on does the pushing. Cloudflare does the rest, including a preview deployment for every branch you do not mark as production.
Create the project
- Publish to your live environment once from StaticScope, so the branch exists. See Publish to GitHub Pages, choosing Cloudflare as the host.
- In the Cloudflare dashboard, open Workers & Pages and select Create application.
- Choose the Git option, connect GitHub if asked, and pick the repository.
- Set the project name, the production branch and the build settings below.
- Save and deploy.
Cloudflare may offer to create this as a Pages project or as a Worker with static assets. You do not need to choose; carry on with whichever it offers. Both serve the same files, and the add-on handles the one setting a Worker needs.
Build settings
| Setting | Value |
|---|---|
| Framework preset | None |
| Build command | Empty |
| Output directory | / |
| Production branch | The branch your live environment publishes to |
An empty build command is not a shortcut. Anything Cloudflare runs is a chance to fail on a build that had nothing to do. The files are already at the top of the branch, with index.html at the root, so / is the correct output directory.
The production branch
Cloudflare treats one branch as production and gives every other branch a preview deployment with its own address. Set production to the branch behind StaticScope’s live environment. Everything else, including Staging, becomes a preview.
Previews are automatic. Publish to a Staging environment and Cloudflare builds staging.your-project.pages.dev without any settings on your side. The GitHub add-on adds noindex, nofollow to non-live branches, so those addresses stay out of search engines.
Branch previews are useful, but they are not private. Anyone with the address can read them. If a preview has to stay closed, use Cloudflare Access in front of the preview domain.
404 handling
A Pages project serves your 404.html without any configuration. A Worker with static assets does not, unless its Wrangler config says not_found_handling: "404-page" under assets.
When the environment’s host is set to Cloudflare, the add-on patches wrangler.jsonc, wrangler.json or wrangler.toml on the branch to add that setting, and writes .assetsignore so .git is not uploaded as an asset. It leaves an ignore file alone if it already excludes .git. Moving the environment to another host removes what the add-on wrote, if it is unchanged.
Config files with comments cannot be read as strict JSON, so the patch is skipped when it cannot be applied safely. If your wrangler.jsonc has comments, add the setting by hand and check it after a publish.
Wrong branch, wrong site. If production points at main and StaticScope publishes to production, every deploy is a Cloudflare success and the site never changes. Check the branch on the project before you debug anything else.
Custom domains
- In the Pages project, open Custom domains and add the domain or subdomain.
- Follow the DNS instruction Cloudflare gives. A domain already on Cloudflare takes one click; an external one needs the CNAME it names.
- Change Site address on the StaticScope environment to the domain.
- Build the site again, then publish.
The last two steps are not optional. The build carries absolute URLs, and the add-on does not check the address in the prepared copy. Publish a build made for your-project.pages.dev on your own domain and the site loads, but every canonical tag, sitemap entry and internal link still names the old address.
Cache
Cloudflare caches assets at the edge, and each deployment gets its own file set there. The pages.dev address normally shows a new publish straight away.
The case that catches people is a custom domain on the same Cloudflare account with extra cache rules, or a proxy sitting in front of it. If the pages.dev address is current and your domain is not, purge the cache for the domain, then check any Cache Rules that override the default HTML behaviour.
If you see an old page for minutes at a time, look for a Cache Rule on text/html. Give HTML a short edge TTL and keep the long one for assets.
When the deploy succeeds and the site is wrong
- Production branch mismatch. The most common cause by a distance. The deploy list shows successful builds for a branch nobody visits.
- Output directory. If it points at a subfolder that does not exist, the deploy succeeds with nothing to serve.
- First deploy before the branch existed. Cloudflare cannot deploy a branch that was not there when the project was created. Publish again, then redeploy from the project’s Deployments tab.
- Private repository, no access. Cloudflare needs the GitHub app installed on the repository’s owner.
- A Worker without the 404 setting. Only the error page is wrong, which can be mistaken for as the whole site.
- Old content, current files. Absolute links from a build made for another address. Rebuild after changing the site address.
Limits and unsupported features
Cloudflare Pages Free allows 20,000 files and 25 MiB per file. A site with a large media library can reach the file count, and the deploy fails rather than trimming anything. If you are close, put the media on R2 and link to it.
Netlify Forms only works on Netlify. Use Web3Forms or your own endpoint with the Forms add-on. Pagefind search is a folder of static files, so it needs nothing from Cloudflare. Redirects work through a _redirects file at the top of the branch, which the add-on keeps across publishes.