Cloudflare Pages

Pages hosts your website at the edge — fast, global, free for static sites. You connect a git repo once; from then on every push builds and publishes automatically. No servers, nothing to patch.

The one idea

Your site lives in a git repo (on GitHub). Pages watches the repo: every push to your main branch triggers a fresh build and goes live in a minute or two. Other branches get their own private preview URL. Git is the source of truth; your laptop just holds a working copy.

This is the whole "disaster-proof" trick: you never deploy by hand or drag files anywhere. You push to git, and the live site updates itself.

Connect a repo (once)

In the Cloudflare dashboard: open Workers & Pages (newer dashboards label this Compute / Workers) → Create → connect to Git (shown as Pages → Connect to Git or Import a repository). Pick the repo, then set the build:

Cloudflare reshuffles this dashboard every few months, so exact labels drift. If the menu doesn't match, don't hunt for these words — use the search box at the top and type Pages or Create application. Or skip the clicks entirely: wrangler pages deploy (or "tell your agent to deploy it") is immune to UI changes.
SettingFor a plain HTML site
Framework presetNone
Build command(leave empty)
Build output directory/ (or the folder your HTML is in, e.g. apps/www)
Production branchmain

Click Save and Deploy. You get a live URL like your-project.pages.dev. That's it — the site is on the internet.

Using a framework (Astro, Next, etc.)? Set the build command (npm run build) and the output directory it produces (dist, build…). Ask your agent "what are the Pages build settings for <framework>" if unsure.

Every push deploys

After the first connect you change the site by changing git — nothing else:

# edit files, then:
git add -A
git commit -m "update homepage"
git push        # Pages builds + publishes automatically

Or do the same with Commit + Push buttons in GitHub Desktop. Watch progress under Workers & Pages → your project → Deployments.

Preview deploys (free, per branch)

Push a branch other than main and Pages builds it at its own URL — <branch>.your-project.pages.dev — without touching production. Perfect for trying a redesign and sending a link before it goes live. Merge the branch into main when you're happy.

Headers & redirects

Two optional files in your output directory control caching and routing — no server needed:

FileWhat it does
_headersSet HTTP headers per path — cache rules, security headers, content types.
_redirectsRedirect or rewrite paths — e.g. /old /new 301, or send www to the apex.
Caching gotcha: clean URLs like / and /about/ can get edge-cached and serve a stale page after a deploy. Force revalidation for HTML routes in _headers (Cache-Control: public, max-age=0, must-revalidate) so a deploy is live immediately.

Rollback

Shipped something broken? Open Deployments, find the last good one, and Rollback to this deployment — instant, no rebuild. (Or just git revert and push.) Because every deploy is kept, you can always go back.

The CLI way (wrangler)

Prefer the terminal, or want an agent to do it? wrangler creates and deploys without the dashboard:

npm install -g wrangler
wrangler pages project create my-site
wrangler pages deploy ./   # deploy the current folder

Same result, scriptable. Better still: tell your AI agent "deploy this folder to Cloudflare Pages" and it picks the right command — that's the point, set the process once.

Next: attach your own address — Custom domains → (without breaking email) · The whole path start to finish — Academy: Zero to a live website →