Introduction
Your portfolio is your storefront, and where it's hosted says something before a visitor reads a word. Cloudflare Pages hosts static sites free on infrastructure spanning 300+ cities worldwide — fast everywhere, free forever on the generous tier, with Git-based deploys that rebuild your site on every push.
This is the exact setup running the site you're reading right now: a Next.js static export pushed to GitHub, built and served by Cloudflare Pages.
Why Static + Cloudflare
A static site is a folder of HTML/CSS/JS files — no server code, no databases, nothing to hack or scale. That makes it:
For portfolios, blogs, and documentation, static is almost always the right call.
Step 1: Get a Site to Deploy
Any static site works — plain HTML, or a framework's export. A Next.js static export (as used here) needs one config line:
// next.config.ts
const nextConfig: NextConfig = {
output: "export",
}Then npm run build produces an out/ folder — the entire site. Push the repo to GitHub first (the Git guide covers this).
Step 2: Connect Cloudflare Pages
| Setting | Value (Next.js export) |
|---|---|
| Framework preset | None (or Next.js — static export) |
| Build command | npm run build |
| Build output directory | out |
Two minutes later your site is live at yourproject.pages.dev. From now on, every push to the production branch rebuilds and deploys automatically — and every pull request gets its own preview URL, so you can review changes before they go live.
Step 3: Custom Domain
Within minutes, https://yourdomain.com serves your site with HTTPS. Subdomains (blog.yourdomain.com, app.yourdomain.com for a Streamlit app) attach to other projects the same way.
Step 4: Files Worth Knowing
Two special files in your output directory change behavior:
/old-page /new-page 301
/resume https://example.com/resume.pdf 200/*
X-Frame-Options: DENY
/images/*
Cache-Control: public, max-age=31536000The redirect file is how this site's renamed blog posts keep their old URLs working — old link, 301, new page, no SEO damage.
Common Issues & Fixes
NODE_VERSION to your local version (node -v), or add an .nvmrc file.out, not .next or dist.[assets] block is Workers-only and fails validation (this exact error cost this site one failed deploy).Key Concepts
What to Try Next
FAQ
What does the free tier actually include?
Unlimited bandwidth, 500 builds/month, unlimited sites, unlimited requests. Custom domains and HTTPS included. Nearly everyone never leaves this tier.
Can I run a backend on Pages?
Static files plus Pages Functions — serverless functions in a /functions folder that run on request. Enough for forms, APIs, and light dynamic behavior without a server.
How is this different from GitHub Pages?
Same core idea. Cloudflare's edge is faster in more regions, build minutes are more generous, preview deployments are built-in, and the platform integrates with the rest of Cloudflare (DNS, Workers, analytics) under one roof.