Skip to main content

Migrating from Cloudflare Pages to Workers for Hugo Sites

·527 words·3 mins
Author
Alex Taramasco
I enjoy helping make technology work for people, not the other way around.
Thumbnail designed by freepik.com

Migrating from Cloudflare pages to workers can be as simple as 1, 2, 3

  1. add wrangler.toml to your code
  2. create a new workers application
  3. add custom domain

…. I will however go into more detail below.

Add wrangler.toml
#

In your code directory, create a new toml file in the root of your website, and add the text shown below.


name = "taramasco-tech-main" #this must be lowercase, with dashes only as per cloudflare
compatibility_date = "2025-06-12" #if you aren't sure, put todays date

[assets]
directory = "./public"

Now save this to the root of your website, and sync with Github through your normal process.

Create a new Workers Application
#

Open up Cloudflare, and navigate to “Compute (Workers)” on the left hand menu.

On the top right, select the “Create” blue button

Select “Get started” inside the “Import a repository” option under the “Workers” tab above.

Select your website Git Repository from the list provided (Assuming you have already got your github associated as you have your website in pages.)

Under “Project Name” add the same string you used in “name” in your toml file.

Keep the settings as default, however add “hugo” under the Build Command line.

Select “Create and deploy” at the bottom of the page.

Wait for the Building and deploying dialogue to complete, when you have all 5 areas ticked.

You will now see the phrase “Success! Your project is deployed to Region: Earth” at the top of the page. Well done you have now deployed your site through workers.

Select “Continue to project”

Adding your custom domain
#

To add your custom domain, first you need to disconnect the domain from your old pages project.

On the left hand side menu, select “Workers & Pages” under “Compute (Workers)”.

Select your old site to open the dialogue.

Select “Custom domains” across the menu at the top

Next to your custom domains, click the three dots next to it and select “Remove domain” from the drop down menu.

Select the bright red “Remove domain” button on the popup menu.

This will cause downtime whilst you change over, so from this point forwards, try to complete the steps as quickly as possible.

On the left hand side menu, please open the “Compute (Workers)” and select “Workers & Pages”. Select your new site from the list.

On the menu along the top, select “Settings”.

Under “Domains & Routes”, select “+ Add” at the top right

Select “Custom domain” from the menu that pops out from the right.

Type out your domain in the menu, and select “Add domain” at the bottom of the page.

You may see an error here saying “Please try again later”. If you see this, it is likley that the domain removal is still propagating, so please keep trying until it works.

You have now migrated your domain over to the workers application. Congratulations, your website is now live through Cloudflare workers. At this point, I wouldn’t delete the old site, just incase you want to migrate back (incase of any issues etc), but you can do if you feel comfortable with it working through the new application.

© 2025 Taramasco Tech