TensorFlake

TensorFlake

Thoughts on AI, code, and building things that matter


Getting Started with Astro on Cloudflare Pages

By TensorFlake April 28, 2025 Posted in Tutorial
Getting Started with Astro on Cloudflare Pages

Cloudflare Pages is one of the best free hosting options available for static sites. Combined with Astro’s blazing-fast static output, it is a powerful pairing that costs nothing and deploys globally.

Prerequisites

Step 1 — Push your project to GitHub

If your project is not already on GitHub, create a new repository and push your code:

git init
git add .
git commit -m "initial commit"
git branch -M main
git remote add origin https://github.com/your-username/your-repo.git
git push -u origin main

Step 2 — Connect to Cloudflare Pages

  1. Log in to dash.cloudflare.com
  2. Go to Workers & PagesCreate applicationPages
  3. Click Connect to Git and authorise GitHub
  4. Select your repository
  5. Set these build settings:
    • Build command: npm run build
    • Build output directory: dist
    • Node.js version: 20 (set in Environment Variables as NODE_VERSION=20)
  6. Click Save and Deploy

Cloudflare will build and deploy your site. Every push to main triggers a new deployment automatically.

Step 3 — Add your custom domain

  1. In your Pages project, go to Custom domains
  2. Click Set up a custom domain
  3. Enter tensorflake.com
  4. Cloudflare will automatically add the DNS records if your domain is on Cloudflare

Your site will be live at https://tensorflake.com within minutes.

Automatic Deployments

Once set up, your workflow is:

  1. Write a new post in src/content/article/
  2. git add . && git commit -m "new post" && git push
  3. Cloudflare detects the push and redeploys — usually in under 60 seconds

No servers to manage. No costs. Global CDN included.