← Back to Home
Engineering /

How I Deployed My Astro Blog to Cloudflare Workers

How I deployed Quiet Iterations, an Astro blog, to Cloudflare Workers with GitHub builds, a custom domain, and a few checks before publishing.

A quiet desk with a monitor, laptop and paper notebook.
Photo by Zesan H. / Unsplash ↗

Quiet Iterations is now live on Cloudflare Workers. It is an Astro blog built on a customized Fuwari theme, with articles written in Markdown and the source kept in GitHub.

I want this blog to be a place for programming experiments, side project ideas, and the occasional loose thought. Getting it online gave me the first thing to write about: how the site itself gets published.

An Astro blog, served as static files#

Astro generates the pages during the build. The output includes HTML, styles, browser JavaScript, images, RSS, and sitemaps. Pagefind builds a search index from the generated pages.

Cloudflare then serves the contents of dist/ using Workers Static Assets. There is no application Worker script in this setup. The pages are already built by the time a reader asks for them.

This is the asset section of wrangler.jsonc:

{
"assets": {
"directory": "./dist",
"html_handling": "force-trailing-slash",
"not_found_handling": "404-page"
}
}

The trailing slash setting matches Astro’s URL configuration. The 404 setting tells Cloudflare to serve the generated error page when a path does not exist.

Search also travels with the site. Including Pagefind in the build means the pages and their search index get deployed together. It is a small detail, but I want an article to be findable after publishing it.

From GitHub to Cloudflare Workers#

The repository is connected to Cloudflare Workers Builds. A push to main starts the production build and deployment.

The build command is pnpm run build:production, and the deploy command is pnpm run deploy:cloudflare. These are scripts defined in this project. They generate the site and search index, validate the output, and invoke Wrangler to upload it.

The deploy script checks the production metadata again before uploading. When Cloudflare supplies the build’s branch name, it also checks that the branch is main.

I followed the changes through GitHub’s build status and Cloudflare’s deployment list. Then I opened the public site and checked what had actually arrived there.

The domain and preview needed attention too#

The public address is quietiterations.com, attached to the Worker as a Custom Domain. The domain uses Cloudflare DNS, and Cloudflare manages the associated DNS record and HTTPS certificate.

The www address redirects permanently to the HTTPS version without www. I checked this with an article URL and a query string: both survived the redirect. The HTTP version redirects to HTTPS too.

Preview builds needed their own rules. They use a separate origin and include noindex, nofollow. Production builds generate URLs for the public domain. A validation step prevents preview output from passing the production deployment checks.

That matters because a page can look completely fine while its canonical URL points at the wrong site.

After deployment, I checked the sitemap URLs, RSS, images, search, and redirects. Unknown paths returned a real HTTP 404. The archive also kept its article links when JavaScript was disabled.

I verified the domain in Google Search Console and submitted the sitemap index. Google reported a successful read; indexing the individual pages comes next.

Back to writing#

The publishing routine is now something I can repeat: prepare a Markdown draft, review it, publish the change through GitHub, and check the live page.

That is a useful starting point for this blog. I can get back to Python, small projects, and writing down what I learn along the way. This deployment is the first entry in that timeline.

Thanks for reading.
Keep a little room for curiosity. — Q.