Skip to main content
Best Web Developer logo
Language and currency EN £ GBP

Language

Currency

Prices on this site are shown in the currency you choose.

Insight

Deploying a Website to Cloudflare Pages with Custom Domain

A practical walkthrough for deploying a website to Cloudflare Pages: Git or direct upload, build settings, apex and www custom domains, SSL, redirects, headers, and the mistakes that break launches.

  • 28 November 2026
  • 14 min read
  • Tutorials

Last updated: September 2026 · Reading time: 13 min · By the Best Web Developer team

Developer dashboard showing a site deployed to Cloudflare Pages with a custom domain and active SSL certificate
From Git push to a live custom domain with HTTPS usually takes under 30 minutes when DNS is already on Cloudflare.

Quick answer

To deploy on Cloudflare Pages, connect your GitHub or GitLab repository (or upload a build folder with Wrangler), set the build command and output directory, and deploy to a free pages.dev address. Then open Custom domains, add your domain, and let Cloudflare create the DNS record and SSL certificate. Apex domains need the zone on Cloudflare; subdomains can use a CNAME.

Key takeaways

  • Cloudflare Pages hosts static and hybrid sites on Cloudflare’s global edge network, with a generous free plan that suits most business websites.
  • Git integration gives you automatic builds, a preview URL for every branch, and one-click rollbacks.
  • An apex domain such as example.sa needs its DNS zone on Cloudflare; a subdomain such as www can point elsewhere with a CNAME.
  • Most failed launches come from three errors: wrong output directory, conflicting DNS records, and an old CAA record blocking the certificate.
  • Add a _redirects and _headers file before launch so www, trailing slashes and security headers are right from day one.

Why Cloudflare Pages is a sensible home for business websites

Cloudflare Pages is a sensible home for most marketing sites, landing pages and documentation because it is fast, cheap and hard to break. You push code, it builds, and the result is served from data centres close to your visitors.

Cloudflare Pages is a hosting platform that builds a website from your code repository and serves the finished files from Cloudflare’s edge network, with optional serverless functions for dynamic features. It replaces the traditional shared server or virtual machine that you patch and monitor yourself.

For Saudi businesses the appeal is practical. Cloudflare runs edge locations inside the Kingdom, including Riyadh and Jeddah, so Arabic and English pages load quickly on mobile networks across the country. There is no server to secure, which reduces the operational burden that usually falls on a small marketing team.

Note: What this guide covers

Screens and menu names in the Cloudflare dashboard change from time to time. The concepts here (project, build settings, custom domains, DNS records, redirects and headers) have been stable for several years. If a label differs, look for the same setting under Workers and Pages in your account.


How Cloudflare Pages works before you deploy

Every project on Cloudflare Pages has a source (Git or direct upload), a build step, and an output folder that becomes the live site. Understanding those three parts prevents most first-deploy failures.

Git integration or direct upload

With Git integration, you authorise Cloudflare to read a GitHub or GitLab repository. Every push to the production branch triggers a build, and every other branch or pull request gets its own preview URL. This is the option we recommend for teams, because the repository becomes the single record of what is live.

Direct upload skips the build on Cloudflare. You build locally or in your own CI pipeline, then send the finished folder with the Wrangler command line tool, for example npx wrangler pages deploy dist.

Build command and output directory

The build command is what Cloudflare runs, such as npm run build. The output directory is where the finished HTML, CSS and JavaScript land. Common values are dist for Astro and Vite, out for a static Next.js export, build for Create React App, and public for Hugo. A plain HTML site needs no build command and uses the folder that holds index.html.

Preview deployments and rollbacks

Each deployment is immutable and gets its own unique URL. If a release breaks something, you can promote an earlier deployment back to production in seconds.

Limits worth knowing

The free plan allows a monthly quota of builds (500 at the time of writing), a cap on files per deployment and a maximum size per file. Very large media libraries belong in object storage such as Cloudflare R2 rather than inside the site build. Check the current limits on the Cloudflare website before planning a site with thousands of pages.

Highlight: Plain HTML works too

You do not need a framework to use Cloudflare Pages. A folder with index.html, a CSS file and images deploys exactly the same way, which makes it a good first home for a simple bilingual company profile.


Step-by-step: deploy to Cloudflare Pages and add a custom domain

The full process has eight steps and usually takes 20 to 40 minutes. The domain step is the only one that may involve waiting, because DNS changes need time to spread.

  1. Prepare the repository. Confirm the site builds locally with the same Node version you will use on Cloudflare. Pin it with a .nvmrc file or the NODE_VERSION environment variable.
  2. Create the project. In the Cloudflare dashboard, open Workers and Pages, choose Create, then Pages, then connect to Git. Select the repository and the production branch, usually main.
  3. Set build settings. Pick the framework preset if one exists, then check the build command and output directory by hand. Add environment variables such as API keys for forms or analytics.
  4. Deploy. The first build runs automatically. When it finishes, the site is live at a project-name.pages.dev address. Test every page on a phone before touching DNS.
  5. Add the custom domain. Open the project, choose Custom domains, then Set up a custom domain. Enter the apex, such as example.sa, and repeat for www.example.sa.
  6. Let Cloudflare create DNS records. If the zone is already on Cloudflare, it adds the CNAME records for you. If the domain is managed elsewhere, you will be shown the record to create at your registrar (only possible for subdomains).
  7. Wait for the certificate. Status moves from Verifying to Active once DNS resolves and the SSL certificate is issued, usually within minutes and occasionally up to 24 hours.
  8. Redirect and harden. Choose one canonical host (www or apex), redirect the other to it, and add security headers. The next section shows how.
Cloudflare Pages custom domain screen with apex and www records pointing to the pages.dev project
Add both the apex and the www host, then redirect one to the other so search engines see a single version.

Apex domain versus subdomain

An apex domain is the bare domain without a prefix, such as example.sa. DNS rules do not allow a normal CNAME at the apex, so Cloudflare uses CNAME flattening, which only works when your nameservers point to Cloudflare. A subdomain such as www or shop can live on any DNS provider with a simple CNAME to project-name.pages.dev.

If your .sa or .com.sa domain sits with a local registrar, you have two options. Move the nameservers to Cloudflare (recommended, and still free), or keep DNS where it is and use www as the main host with a redirect from the apex configured at the registrar.

Pro tip

Before you switch nameservers, export every existing DNS record, especially MX, SPF, DKIM and DMARC for email. Cloudflare’s import scan catches most records, but we always compare the list line by line. A missed MX record is the most common way a website launch takes down company email.


Redirects, headers and the settings that finish the job

A deployment is not finished when the page loads. Canonical redirects, caching and security headers decide how search engines and browsers treat the site.

The _redirects file

Place a plain-text file called _redirects in the output folder. Each line holds a source, a destination and a status code, for example /old-services /services 301. Use it to preserve URLs from a previous WordPress site so rankings and backlinks carry over. For the www to apex redirect, use a Cloudflare Redirect Rule at zone level, because _redirects only matches paths, not hostnames.

The _headers file

A _headers file sets HTTP headers by path. We add Strict-Transport-Security, X-Content-Type-Options, Referrer-Policy, a Permissions-Policy and a Content-Security-Policy tuned to the scripts the site actually uses. Long cache lifetimes go on fingerprinted assets such as /assets/*, while HTML stays short so updates appear immediately.

Functions for forms and small dynamic features

Pages Functions let you run server-side code from a /functions folder, for contact forms, simple APIs or geolocation-based language suggestions. Keep personal data handling in mind: if a form collects names and phone numbers from Saudi visitors, the Personal Data Protection Law applies to how you store and transfer that data. SDAIA publishes the law and its regulations on its regulations and policies page.

Search and performance checks after launch

Submit the sitemap in Google Search Console and Bing Webmaster Tools, check that robots.txt does not block the new domain, and confirm that preview URLs on pages.dev are not indexed. Our free robots.txt generator builds a clean file in a minute. Then test the live domain against Google’s Core Web Vitals thresholds: LCP at or under 2.5 seconds, INP at or under 200 milliseconds and CLS at or under 0.1.

Highlight: Our launch checklist in one line

Build passes, pages.dev tested on mobile, DNS exported, custom domains Active, one canonical host, 301 map live, headers set, robots.txt and sitemap checked, Search Console verified, Core Web Vitals green.


Key benefits of Cloudflare Pages for business sites

The main benefits are speed, security and low running cost, with a workflow that non-developers can follow through preview links.

  • Low cost: the free plan covers most corporate and campaign sites; paid add-ons start at about $5 a month (roughly SAR 19) for higher Functions usage.
  • Global and local speed: files are cached on the edge, including locations in Saudi Arabia, so first loads are fast for visitors in Riyadh, Jeddah and Dammam.
  • No server patching: there is no operating system, PHP version or plugin stack to update, which removes the most common attack paths for small sites.
  • Free SSL and DDoS protection: certificates renew automatically and traffic spikes during Ramadan or Saudi National Day campaigns are absorbed by the network.
  • Safe releases: preview URLs for every branch and instant rollbacks lower the risk of each change.
“The best hosting setup is the one your team cannot accidentally break at 11 pm before a campaign launch.”
— Best Web Developer strategy team

Use cases: when Cloudflare Pages fits a Saudi Arabia business

Cloudflare Pages fits sites where content changes through a developer workflow or a headless CMS, and where most pages can be pre-built. It is a weaker fit when the business logic lives in a large database application.

Bilingual corporate and landing pages

Company profiles, campaign pages and investor sites in Arabic and English are ideal. Each language can live in its own folder (/ar/ and /en/) with hreflang tags, and marketing can review changes on a preview link before approval.

Headless CMS and documentation

Pair Pages with a headless CMS so editors publish through a friendly interface and a webhook triggers a rebuild. Product documentation, careers pages and knowledge bases work well this way.

Where it is not the right tool

Full e-commerce stores that need live stock, mada and STC Pay checkout and ZATCA-compliant invoices are usually better on Salla, Zid, Shopify or a custom back end. You can still put a fast Pages-hosted marketing site in front of the store. Our web development service often splits projects this way.

Illustrative case: a Riyadh consultancy moves off shared hosting

Challenge: A 14-page bilingual consultancy site ran on shared hosting at SAR 1,400 a year, with a 4.8 s mobile LCP and two malware clean-ups in 12 months.

What we did: We rebuilt it as a static Astro site, deployed it to Cloudflare Pages, moved DNS to Cloudflare with every email record preserved, and mapped 62 old URLs with 301 redirects. Project cost was SAR 18,500.

Result: Mobile LCP dropped from 4.8 s to 1.6 s, hosting cost fell to zero on the free plan, and organic enquiries rose from about 19 to 31 a month within four months, with no security incidents since launch.


Cloudflare Pages vs other static hosting options

Cloudflare Pages, Netlify, Vercel and GitHub Pages all deploy static sites from Git; the differences are in free-tier limits, edge coverage and framework features. The table summarises how we choose.

OptionBest forFree tier in practiceCustom domain and SSLWatch out for
Cloudflare PagesMarketing sites, bilingual content, global reachGenerous bandwidth, monthly build quotaAutomatic; apex needs Cloudflare DNSFile count and size limits per deployment
NetlifyTeams wanting built-in forms and pluginsBandwidth and build-minute capsAutomatic on any DNSUsage-based charges once limits are passed
VercelNext.js apps with server renderingHobby plan is for non-commercial useAutomatic on any DNSBusiness use needs a paid Pro seat
GitHub PagesOpen-source docs and simple sitesFree for public repositoriesSupported, fewer optionsNo server functions, limited headers control
Shared or VPS hostingWordPress and PHP sitesRarely freeManual or via the hostPatching, backups and security are on you

For a typical Saudi SME site, we choose Cloudflare Pages when the site is mostly content and Vercel when a Next.js application needs server rendering on every request. Our Riyadh web design team can advise on which fits your stack.


Frequently Asked Questions about Cloudflare Pages

How do I add a custom domain to Cloudflare Pages?

Open your project in the Cloudflare dashboard, go to Custom domains and choose Set up a custom domain. Enter the domain, such as www.example.com, and confirm. If the DNS zone is on Cloudflare, the record is created automatically; otherwise you add a CNAME pointing to your pages.dev address at your DNS provider. The status turns Active once DNS resolves and the SSL certificate is issued.

Why is my Cloudflare Pages custom domain stuck on verifying?

The usual causes are a conflicting A or CNAME record for the same hostname, a CAA record that does not allow Cloudflare’s certificate authorities, or DNS changes that have not spread yet. Delete old records for that host, check CAA entries, and wait up to 24 hours. For an apex domain, confirm the nameservers really point to Cloudflare, because apex setups only work with Cloudflare DNS.

Is Cloudflare Pages free for business websites?

Yes. The free plan allows commercial use and includes hosting, SSL and a monthly quota of builds, which covers most company, campaign and documentation sites. Paid plans add higher build limits, more concurrent builds and larger Functions usage. A Workers paid plan starts at about $5 a month, which is roughly SAR 19, so costs stay low even when you add dynamic features.

Can I host a Saudi business website on Cloudflare Pages?

Yes. Many Saudi companies host bilingual marketing sites on Cloudflare Pages, and Cloudflare’s network includes edge locations inside the Kingdom, which helps local load times. If your site collects personal data through forms or bookings, the PDPL applies to how that data is stored and transferred, so document where submissions go. Stores needing mada or ZATCA invoicing usually run checkout on a dedicated platform.

How do I deploy a React or Astro site to Cloudflare Pages from GitHub?

Push the project to GitHub, then create a Pages project and connect the repository. Choose the framework preset, confirm the build command (usually npm run build) and the output folder (dist for Astro and Vite, build for Create React App). Set the Node version with an environment variable if needed. Every push to main then deploys to production, and other branches get preview URLs.

Should my main domain be www or the apex on Cloudflare Pages?

Either works for SEO as long as you pick one and redirect the other with a 301. The apex looks cleaner on printed material, while www is easier when your DNS stays with an external registrar because it only needs a CNAME. Add both hostnames to the project, choose the canonical version, and set a zone-level redirect rule for the other one.

Does Cloudflare Pages support redirects and security headers?

Yes. Add a _redirects file to your output folder for path-based redirects with status codes such as 301 or 302, and a _headers file to set HTTP headers by path. Use them for old URL mappings, cache rules and headers like Strict-Transport-Security and Content-Security-Policy. Hostname redirects, such as www to apex, are best handled with a Cloudflare Redirect Rule.

Launching on Cloudflare Pages with confidence

Cloudflare Pages gives most business websites fast global delivery, free SSL and safe releases without a server to maintain. The deployment itself is quick; the care goes into DNS, redirects and headers.

Build locally first, test the pages.dev address on a phone, export your DNS before any nameserver change, and pick one canonical host. Follow that order and a custom domain launch on Cloudflare Pages becomes a routine 30-minute task rather than a risky evening.

Want a launch that does not break email or rankings?

We plan the DNS move, redirect map and headers, then deploy and monitor your site on Cloudflare Pages, with quotes in SAR.

Book a free deployment review See pricing
Tags: Cloudflare Pages, custom domain, static site hosting, DNS setup, SSL certificate, Wrangler, redirects and headers, Jamstack, website deployment, Saudi web hosting, Vision 2030

Frequently asked questions

What does this page cover?

Deploying a Website to Cloudflare Pages with Custom Domain explains a practical walkthrough for deploying a website to Cloudflare Pages: Git or direct upload, build settings, apex and www custom domains, SSL, redirects, headers, and… in practical terms: what it means, when it applies and what to do next. It is written for business owners and developers rather than for search engines, with the technical detail kept where it is useful.

Who is this written for?

Owners and marketing leads who need to make a decision, plus developers who want the implementation detail. Jargon is explained on first use and every recommendation can be acted on without buying anything.

Is this information current?

It is reviewed against current Google documentation and observed client results, and updated when the guidance changes. Anything time-sensitive is dated in the copy rather than left to drift.

Is it free to read?

Yes, with no paywall, no email gate and no signup. If it is useful, the only thing we ask is that you link to it when you quote it.

Can you implement this for us?

Yes. The same team that writes these guides delivers the work, so the advice and the implementation come from the same place rather than a content team and a separate agency.

Where can I read more?

Related guides, services and free tools are linked at the end of this page, and the full library is indexed in the sitemap so you can find the topic closest to your question.

Do you accept corrections?

Yes. If something here is out of date or wrong, tell us and it gets fixed with a visible update. Accurate technical writing is worth more to us than being right in public.

Need help implementing this?

Best Web Developer gives you a fixed quote, a dated plan and a senior developer who stays on the project from first call to launch. No account managers, no hourly surprises.

Request a quoteSee pricing

Want this handled for you?

We build and optimise sites like this every week. Book a free 30-minute call and we will tell you exactly what we would change on yours.

Get a free site review

Keep reading

Free strategy session

Let’s build something worth finding.

Tell us where you want the business to be in twelve months. We will come back with a costed plan, a realistic timeline, and the numbers we expect to move — no obligation, no jargon.

  • 30-minute call, no pitch deck
  • Fixed-price proposal in 48 hours
  • You own everything we build

Talk to a developer

Not a sales team

Response time
Within 1 business hour
Where we work
UK, USA & the Gulf
Contracts
No lock-in, monthly rolling
Working since
2023
infobestwebdeveloper.org
Free consultation

show prices in USD?

Get a free quoteWe reply within 1 business hour