Deploying to Cloudflare Pages – The Complete Guide

Everything you need to know to deploy a static site to Cloudflare Pages, from initial setup to custom domains and automatic deployments.

Tue Mar 10 2026 00:00:00 GMT+0000 (Coordinated Universal Time)

Deploying to Cloudflare Pages

Cloudflare Pages is one of the best platforms for hosting static sites. Here’s why and how.

Why Cloudflare Pages?

  • Edge network – Your site is served from 300+ locations worldwide
  • Generous free tier – Unlimited requests, 500 builds/month
  • Automatic HTTPS – SSL certificates handled automatically
  • Git integration – Push to deploy, preview deployments on every PR
  • Custom domains – Free, including www redirects

Setup Steps

1. Connect Your Repository

  1. Go to dash.cloudflare.com
  2. Navigate to PagesCreate a project
  3. Connect your GitHub/GitLab repository

2. Configure Build Settings

For an Astro project:

SettingValue
Framework presetAstro
Build commandpnpm build
Build output directorydist
Node.js version20.x

3. Add Environment Variables

If your build requires environment variables, add them in the Pages dashboard under SettingsEnvironment variables.

4. Custom Domain

  1. Go to Custom domains in your project
  2. Enter your domain name
  3. Follow the DNS setup instructions

Since my domain is already managed by Cloudflare, the DNS records are added automatically.

Automatic Deployments

Every push to main triggers a production deployment. Every PR gets a unique preview URL – perfect for reviewing changes before merging.

That’s it! The whole setup takes about 5 minutes.