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.
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:
Pages or Create application. Or skip the clicks entirely: wrangler pages deploy (or "tell your agent to deploy it") is immune to UI changes.| Setting | For a plain HTML site |
|---|---|
| Framework preset | None |
| Build command | (leave empty) |
| Build output directory | / (or the folder your HTML is in, e.g. apps/www) |
| Production branch | main |
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:
| File | What it does |
|---|---|
_headers | Set HTTP headers per path — cache rules, security headers, content types. |
_redirects | Redirect or rewrite paths — e.g. /old /new 301, or send www to the apex. |
/ 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.