Every Cloudflare Pages project gets a free address like my-site.pages.dev. It works, but you’ll want your own domain before you share the site. This tutorial shows you how to add a custom domain to Cloudflare Pages, whether your domain is already on Cloudflare or not, and how to send visitors from the old addresses to the new one.
What you need
- A Pages project that has deployed at least once. If you haven’t got one yet, start with our guide to hosting a static site on Cloudflare Pages.
- A domain you own, and access to wherever its DNS is managed.
- For a root domain like
example.com(an “apex” domain): the domain must be added to the same Cloudflare account as your Pages project, using Cloudflare’s nameservers.
Add the domain in Pages first
- In the Cloudflare dashboard, go to Workers & Pages and select your Pages project.
- Open the Custom domains tab and select Set up a custom domain.
- Type the domain or subdomain, such as
example.comorblog.example.com, and select Continue. - Select Activate domain.
Add the domain here before you touch DNS. A DNS record that points at your pages.dev address without the domain added to the project won’t serve your site.
If the domain’s DNS is on Cloudflare
This is the easy case. When you activate the domain, Cloudflare creates the DNS record for you, a CNAME pointing to your project.pages.dev address, and issues an SSL certificate automatically. For an apex domain, Cloudflare handles the fact that a root domain normally can’t have a CNAME by “flattening” it behind the scenes. Wait a few minutes and the status changes to Active.
If the DNS is somewhere else (subdomains only)
You can use a subdomain such as www.example.com or blog.example.com while keeping your DNS at another provider:
- Add the subdomain in Custom domains as above.
- At your DNS provider, create a CNAME record: name
blog(orwww), targetyour-project.pages.dev. - Back in Cloudflare, wait for the domain to show as Active. This can take longer than on Cloudflare DNS.
For the root domain itself, you’ll need to move the domain’s nameservers to Cloudflare. Your registrar’s control panel has a setting for nameservers; Cloudflare shows the two names to enter when you add the domain to your account.
Redirect www and pages.dev to one address
Search engines prefer one address per page. Pick your main version, example.com or www.example.com, and send everything else there with a permanent (301) redirect:
- www to the root domain: add
wwwas a custom domain too, then create a Bulk Redirect in the dashboard fromwww.example.comtoexample.com. Cloudflare’s Pages docs walk through this as “Redirecting www to domain apex”. - pages.dev to your domain: your project’s pages.dev address stays online. Cloudflare’s guide “Redirecting *.pages.dev to a custom domain” uses Bulk Redirects to send that traffic to your domain, so the old address doesn’t compete with the new one in search results.
Path-level redirects, such as old post URLs, are handled differently, with a _redirects file in your site; see our guide to redirects on Cloudflare Pages.
Common mistakes
- Adding the DNS record first. Add the custom domain in the Pages project, then the record.
- An old A or CNAME record in the way. Delete any existing record for the same name before you add the domain.
- Forgetting www. Add both versions and redirect one to the other, or half your visitors may hit an error.
- Moving a live site without redirects. If you’re moving from another platform, our tutorial on moving WordPress to a static site covers keeping your old URLs working.
FAQ
How long does it take for the domain to work?
If the domain is already on Cloudflare, usually a few minutes, including the security certificate. If you've just moved your nameservers to Cloudflare, it can take longer while the change spreads, occasionally up to a day.
Can I use the same domain on two Pages projects?
Not the same hostname, but different subdomains can point to different projects, for example the main site on example.com and a docs project on docs.example.com.



