ndza

Cloudflare Pages to Workers migration

Why migrate

I took an easy path a while back, when setting up this site. I sort of knew that Cloudflare Pages was being phased out and replaced by Cloudflare Workers, but it was just so easy to use Pages as I wanted something quick.

Now this banner bothers me, so I should probably do something about it:

A screenshot of Cloudflare's banner to remind about Pages to Workers migration

Hopefully, this is an easy exercise. Let's get in.

Prep reading

Looking at the compatibility matrix I can see that most of the functionality in Pages is covered by Workers.

Now, I don't use a lot of the features. This is deliberate, so that I reduce my dependencies on Cloudflare, but I do use Branch Deploy Controls. It looks like there's some limitation, it might be a problem - not sure: A screenshot of Cloudflare's compatibility matrix - branch deploy controls

Looking at the migration guide I can see that 11ty is not in the list of "popular frameworks", so it's not supported through their adapters.

The work

wrangler.jsonc

First thing we need is to create a wrangler config file:

{
  "name": "eleventy-base-blog-worker",
  "compatibility_date": "2025-06-27",
  "assets": {
    "directory": "./_site/",
    "not_found_handling": "404-page"
  }
}

I don't use functions, so I've set the compatibility_date to today. The site uses 11ty and builds into _site so, I have to set that. Because the site is not an SPA, I have to ensure the 404.html page is used for for not found.

Before adding this file to main branch, I had to pause automatic deployments.

Creating the Cloudflare Worker

Then we proceed to creating the worker. I have to import my project from git and I gave it a name.

I had to also specify the build command:

npx @11ty/eleventy

And a deploy command, which already defaulted to:

npx wrangler deploy

Then I saw the build run and the deploy go through successfully and was able to see the website running on a workers.dev sub-domain. I was able to test it.

Custom domain name

Then I had to manage the DNS records for my domain. I deleted the record that points to the Pages project. And in the worker settings I had to add a the domain as a custom domain.

Removing older CloudFlare Pages project

This is a matter of deleting the Pages project.

But, I won't do that for a few hours/days - as DNS changes usually take a while to propagate and I want to look at a few analytics in there.

Easy peasy!

That was easy! The new way is Workers. So, I wonder what I'll miss from the old way.

As I write this, I've already noticed that Branch Preview URL, mentioned in this post is not available on the PR, only Commit Preview URL is: A screenshot of Cloudflare's preview urls on PR

This is not a deal-breaker. As I test the site, everything else works. So, ba-bye Pages!