How to Connect a Custom Domain on Cloudflare Pages
A *.pages.dev URL proves your static site deploys correctly, but visitors trust a branded domain. Connecting a custom domain on Cloudflare Pages routes HTTPS traffic from yourproduct.com to the same HTML files you already ship from Git. This how-to follows the official Cloudflare Pages custom domain workflow and adds practical checks indie hackers use before announcing a launch.
What you need before you start
You need an active Cloudflare Pages project with at least one successful production deploy. You also need a domain you control, either purchased through Cloudflare Registrar or registered elsewhere (Namecheap, Google Domains successor, Porkbun, etc.). If the domain is new, finish registration and unlock the registrar account so you can change nameservers or add DNS records. Cloudflare issues free Universal SSL certificates automatically once DNS validates; no manual certificate upload is required for standard static sites.
- Cloudflare account with Pages project deployed
- Domain registered and accessible in a registrar dashboard
- Roughly 15–60 minutes for DNS propagation (often faster)
- Optional: access to your previous host if migrating an existing site
Choose your DNS strategy
Cloudflare supports two common setups. Full Cloudflare DNS means you move nameservers to Cloudflare and manage every record in one dashboard—recommended when Pages is your only host. Partial setup (CNAME flattening) keeps your registrar DNS but points specific records at Pages; some registrars do not support apex CNAME, which is why many teams move DNS to Cloudflare anyway. For a marketing landing page, full Cloudflare DNS simplifies SSL renewal, redirect rules, and future email records.
Add the domain inside Cloudflare Pages
Open the Cloudflare dashboard, navigate to Workers & Pages, and select your project. Go to Custom domains and click Set up a custom domain. Enter the exact hostname you want—typically the apex example.com and optionally www.example.com. Cloudflare will show the DNS records it expects. Accept the suggested configuration unless you have a deliberate split setup (for example, docs.example.com hosted elsewhere).
# Example: Pages shows you something like
# Apex (example.com) -> CNAME to your-project.pages.dev (flattened)
# www (www.example.com) -> CNAME your-project.pages.dev
If your domain is already on the same Cloudflare account, Pages can often attach records automatically. Confirm the status column reads Active or Pending with clear next steps. Pending usually means DNS has not propagated yet, not that you misconfigured Pages.
Configure DNS at your registrar
When the domain is external, Cloudflare prompts you to add nameservers. Copy the two (sometimes four) assigned nameservers and paste them into your registrar's DNS settings, replacing the defaults. Save and wait. Registrar UIs label this field "Custom DNS," "Nameservers," or "Delegate DNS." Changes can take up to 24 hours but often complete within an hour. You can monitor progress with dig NS example.com or an online DNS checker.
- Log into your registrar and open DNS / nameserver settings.
- Switch from default nameservers to Cloudflare's assigned pair.
- Save changes and note the timestamp for troubleshooting.
- Return to Cloudflare; the domain status should move from Pending to Active.
- In Pages → Custom domains, verify both apex and www show Active.
Force HTTPS and pick a canonical host
Browsers and search engines treat www.example.com and example.com as separate URLs unless you redirect one to the other. In Cloudflare, open SSL/TLS and ensure mode is Full or Full (strict) for Pages origins. Then create a Redirect Rule (or Bulk Redirect) sending www to apex—or the reverse if your brand prefers www. Pick one canonical URL and use it in link rel="canonical" tags across every HTML file. Consistency prevents duplicate indexing and split analytics.
<!-- In every page <head> -->
<link rel="canonical" href="https://example.com/how-to/page.html">
Verify SSL, caching, and live content
Visit https://example.com in a private browser window. Confirm the padlock appears, CSS loads, and forms submit to the correct endpoint. Check response headers in DevTools Network tab: Cloudflare should serve cf-cache-status on static assets. Purge cache under Caching → Configuration → Purge Everything if you still see an old parking page. Test from mobile data, not just office Wi-Fi, to avoid stale DNS caches on your laptop.
- Apex domain loads your latest Pages deploy
- www redirects to canonical host with 301
- Certificate is valid (no mixed-content warnings)
- sitemap.xml and robots.txt use https://example.com URLs
- Form endpoints and analytics still receive events
Troubleshooting common failures
Too many redirects: Usually a conflict between Cloudflare SSL mode and an origin redirect loop. Set SSL to Full (strict) and remove duplicate page rules. 522 / 525 errors: Often appear when a DNS record still points at a retired host; delete obsolete A records pointing at old IPs. Domain stuck on Pending: Nameservers may not have propagated; double-check for typos and that the registrar actually saved changes. Wrong site content: You attached the domain to a different Pages project—detach and reconnect to the correct project.
After the domain goes live
Update absolute URLs in sitemap.xml, Open Graph tags, and email templates. Submit the new property in Google Search Console and Bing Webmaster Tools. If you use Formspree or Umami, add the production domain to allowed origins or site settings. Run through the LaunchStatic deployment checklist one more time on the live hostname before sharing the link publicly.
Email and subdomain planning
Connecting a marketing domain does not automatically configure email. If you send mail from @example.com, add MX records separately in Cloudflare DNS—do not point MX at Pages. Common patterns keep the apex on Pages, route www to the same project, and host docs at docs.example.com on another Pages project or host. Document each subdomain in your internal runbook so a future you does not wonder why status.example.com resolves unexpectedly.
Related: Deploy to Cloudflare Pages Deploy on GitHub Pages Generate sitemap.xml Free tools for static sites Browse landing page templates
Can I use Cloudflare Pages without moving nameservers?
Sometimes, if your registrar supports CNAME on the apex or you only need www. Most teams move DNS to Cloudflare because apex support and free SSL are simpler in one dashboard.
How long until HTTPS works on my custom domain?
After nameservers propagate, Cloudflare typically provisions Universal SSL within minutes to a few hours. You can track certificate status under SSL/TLS → Edge Certificates.
Should I use www or non-www?
Either is fine—pick one canonical host, redirect the other with a 301, and match your canonical link tags and sitemap URLs.
Will connecting a domain break my pages.dev URL?
No. The *.pages.dev subdomain keeps working alongside your custom domain unless you disable it in project settings.
Ship on your own domain
Start from a LaunchStatic template, deploy to Cloudflare Pages, then attach your domain in one afternoon.
Browse templates Full deploy guide