Logo Ernie.SG
Moving to Cloudflare Pages with Astro

Moving to Cloudflare Pages with Astro

March 21, 2024
3 min read
Table of Contents

Moving to Cloudflare Pages with Astro

Would you like to write Markdown, enjoy version control and auto-deploy, attain lightning-fast SEO and setup, use your own domain with SSL and unlimited bandwidth for your personal site - all for FREE? Then read on!

Making the switch to Cloudflare Pages for hosting my website was driven by several compelling factors. Here’s why I made this decision:

Why Astro?

Astro has become my framework of choice for several compelling reasons:

Lightning-Fast SEO

  • Zero JavaScript by default, resulting in blazing-fast page loads
  • 99/100 Lighthouse scores out of the box
  • Automated meta tags and structured data

Content-Driven

  • First-class Markdown/MDX support so you can easily re-render your content as desired
  • Native LaTeX support for math
  • Rich syntax highlighting for 100+ languages

Flexible Developer Experience

  • Framework-agnostic: Use React, Vue, Svelte, or HTMX where needed
  • Static output means hosting anywhere, no vendor lock-in

The Benefits of Cloudflare Pages

Unlimited Bandwidth

One of the main reasons I switched was Cloudflare Pages’ generous free tier offering unlimited bandwidth. This means no surprise bills just in case I become famous!

Automated CI/CD

The development workflow is seamless with:

  • Automatic deployments from Git
  • Preview deployments for pull requests
  • Easy rollbacks

Custom Domains and More

  • Global CDN with edge caching
  • Automatic asset optimization
  • Custom domains with easy setup (you have to pay for this yourself of course)
  • Built-in SSL certificates
  • Built-in analytics
  • Great documentation

The Migration Process

To do so, here’s what I did:

  1. Cloned the astro-erudite template

  2. Customized and pushed to GitHub

  3. Set up Cloudflare Pages and deployed:

    • Navigated to Cloudflare dashboard > Compute (Workers)
    • Connected GitHub repository
    • Selected main branch for deployment
    • Selected Astro as the framework
  4. Connected custom domain and let Cloudflare take care of the rest from hereon

The entire process was as easy as it gets. I get free version control and the site automatically redeploys when I push to main.

Conclusion

The combination of Astro’s performance-first approach and Cloudflare’s robust infrastructure provides an excellent foundation for developers looking for a quick home on the internet. The best part? It’s all available for free, making it an ideal choice for personal projects and blogs.