Migrating from Workers Sites to Pages
Cloudflare Pages provides built-in defaults for every aspect of serving your site. Currently, you cannot port custom behavior in your Workers script — such as custom caching logic — over to your Cloudflare Pages. If you need that behavior, keep using your Cloudflare Workers application.
If you did not need to customize a Workers Sites template, migrating your static site to Cloudflare Pages will be easy to do. You will be able to access features like and automatic branch deploys with no extra configuration needed.
Removing unnecessary code
Workers Sites projects consist of the following pieces:
- If using a static site tool, a build directory (called
wrangler.toml) where the static project builds HTML, CSS, and JS
- A Workers application for serving that directory
When moving to Cloudflare Pages, remove the Workers application, and any associated
wrangler.toml configuration files or build output. Instead, note and record your build command (if you have one), and the
bucket field, or build directory, from the
wrangler.toml file in your project's directory.
Creating a new Pages project
After you have recorded your build command and build directory in a separate location, remove everything else from your application, and push the new version of your project up to GitHub. Follow the to add your project to Cloudflare Pages, using the build command and build directory that you saved earlier.
If you choose to use a custom domain for your Pages, you can set it to the same custom domain as your currently deployed Workers application. When Pages finishes the initial deploy of your site, you will need to delete the Workers application to start sending requests to Cloudflare Pages.
Cleaning up your old application and assigning the domain
With your Workers application removed, requests will go to your Pages application. By completing this guide, you have successfully migrated your Workers Sites project to Cloudflare Pages.