What I Wanted to Do
I wanted to publish my Astro site using Cloudflare Pages.
Environment
- Windows 11
- Node.js
- Astro
- GitHub
- Cloudflare Pages
Steps
1. Install Astro
npm create astro@latest
2. Verify Locally
cd project-name
npm run dev
If the Astro welcome screen appears at http://localhost:4321, you are good to go.
3. Push to GitHub
If this is your first time pushing to GitHub, see How to Push to GitHub for the First Time.
git init
git add .
git commit -m "first commit"
git remote add origin YOUR_GITHUB_URL
git push -u origin main
4. Connect to Cloudflare Pages
- Go to “Workers & Pages” → “Create application”
- Click “Looking to deploy Pages? Get started” at the bottom of the screen
- Click “Import an existing Git repository” → “Get started”
- Select your repository
- Choose “Astro” from the Framework preset dropdown
- Click “Save and Deploy”
Gotchas
- Clicking “Create application” opens the Workers screen. For Pages, use “Get started” at the bottom of the page
- Selecting the Astro framework preset automatically fills in the build settings
- If you need to set environment variables after deployment, see How to Set Environment Variables in Cloudflare Pages
Related Articles
- Full Steps to Set an Xserver Domain as a Cloudflare Pages Custom Domain
- Cloudflare Pages GitHub Auto-Deploy Not Working: How to Fix It
- How to Read Cloudflare Pages Build Logs and Fix Errors
- How to Add a New Page in Astro
Recommended Services
- Fiverr - Find freelance developers and tech experts