How to Set Up Cloudflare Pages

Last updated: February 22, 2026

Why Cloudflare Pages?

Cloudflare Pages is a free hosting platform with a global CDN (content delivery network). Your site loads fast from anywhere in the world, and it automatically deploys whenever you push code to GitHub.

What you get for free:

  • Unlimited bandwidth
  • Global CDN
  • Automatic SSL (HTTPS)
  • Preview deployments for branches
  • Serverless functions (for the contact form)

Step 1: Create a Cloudflare Account

  1. Go to cloudflare.com and click Sign Up
  2. Enter your email and create a password
  3. Verify your email

Step 2: Connect Your GitHub Repository

After your site is built (you’ve run the Stage 1 prompt and pushed to GitHub):

  1. In the Cloudflare dashboard, go to Workers & Pages
  2. Click Create
  3. Select the Pages tab
  4. Click Connect to Git
  5. Authorize Cloudflare to access your GitHub account
  6. Select the repository with your site code

Step 3: Configure Build Settings

On the configuration screen:

  • Production branch: main (or master, whichever your repo uses)
  • Build command: bundle exec jekyll build
  • Build output directory: _site

Click Save and Deploy. The first build might take a minute or two.

Step 4: Add Environment Variables

If your site has a contact form, you need to add the SendGrid environment variables:

  1. Go to your Pages project > Settings > Environment variables
  2. Add these variables for the Production environment:
Variable Value
JEKYLL_ENV production
SENDGRID_API_KEY Your SendGrid API key
CONTACT_EMAIL Your business email
FROM_EMAIL noreply@yourdomain.com

Don’t have SendGrid yet? See How to set up SendGrid. If your site doesn’t use a contact form, you only need the JEKYLL_ENV variable.

Step 5: Set Up Your Custom Domain

Once the initial deploy succeeds:

  1. Go to your Pages project > Custom domains
  2. Click Set up a custom domain
  3. Enter your domain (e.g., www.yourbusiness.com)
  4. Cloudflare will tell you what DNS records to add

If your domain is already on Cloudflare: The DNS records are added automatically. Done!

If your domain is registered elsewhere: You have two options:

  • Transfer nameservers to Cloudflare (recommended — gives you full control)
  • Add a CNAME record at your current registrar pointing to your Pages URL

How Deployments Work

Once connected, the workflow is automatic:

  1. You push code to GitHub (to the main branch)
  2. Cloudflare detects the push
  3. It builds your Jekyll site
  4. The new version is deployed globally

This happens in about 30-60 seconds. You can also push to other branches to get preview deployments — useful for testing changes before going live.

Troubleshooting

Build fails with “ruby not found” Make sure your repo includes a .ruby-version file (the Stage 1 prompt creates this). Cloudflare Pages uses it to install the right Ruby version.

Build fails with “bundle not found” This usually resolves itself — Cloudflare Pages installs Bundler automatically. If it persists, try triggering a new deploy.

Custom domain shows “too many redirects” Go to your domain’s SSL/TLS settings in Cloudflare and set the encryption mode to Full (strict).