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
- Go to cloudflare.com and click Sign Up
- Enter your email and create a password
- 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):
- In the Cloudflare dashboard, go to Workers & Pages
- Click Create
- Select the Pages tab
- Click Connect to Git
- Authorize Cloudflare to access your GitHub account
- Select the repository with your site code
Step 3: Configure Build Settings
On the configuration screen:
- Production branch:
main(ormaster, 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:
- Go to your Pages project > Settings > Environment variables
- 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_ENVvariable.
Step 5: Set Up Your Custom Domain
Once the initial deploy succeeds:
- Go to your Pages project > Custom domains
- Click Set up a custom domain
- Enter your domain (e.g.,
www.yourbusiness.com) - 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:
- You push code to GitHub (to the
mainbranch) - Cloudflare detects the push
- It builds your Jekyll site
- 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).