Skip to content

Migrate from GitHub Pages to Workers

This guide walks you through migrating a static site or Jekyll ↗︎ site from GitHub Pages ↗︎ to Cloudflare Workers with Workers Static Assets and Workers Builds.

1. Prepare your repository

Plain HTML or JavaScript static sites

Confirm your project's build command (if any) and static output directory (for example, dist, public, build, or . for pre-built HTML files).

Jekyll sites hosted on GitHub Pages

GitHub Pages preinstalls a default set of Jekyll plugins even when no Gemfile is present. If your Jekyll repository does not already contain a Gemfile and Gemfile.lock, create them so Workers Builds can install your dependencies:

  1. In your repository root, initialize a Gemfile:

    bundle init
  2. Add the github-pages gem to your Gemfile:

    Gemfileruby
    source "https://rubygems.org"
    
    gem "github-pages", group: :jekyll_plugins
  3. Generate Gemfile.lock and commit both files:

    bundle update
    git add Gemfile Gemfile.lock
    git commit -m "Add Gemfile for Jekyll build"

2. Create a Wrangler configuration file

In the root of your repository, create a wrangler.jsonc file pointing assets.directory to your site's output folder (for example, ./_site for Jekyll or . for plain HTML in the repository root):

{
	"name": "<your-project-name>",
	// Set this to today's date
	"compatibility_date": "2026-11-28",
	"assets": {
		"directory": "./_site"
	}
}
name = "<your-project-name>"
# Set this to today's date
compatibility_date = "2026-11-28"

[assets]
directory = "./_site"

If your site is a Single Page Application (SPA) rather than a static site, add "not_found_handling": "single-page-application" inside the assets object. If you have a custom 404.html page, add "not_found_handling": "404-page". Refer to Static Assets routing for details.

Commit and push wrangler.jsonc to your GitHub repository.

3. Connect your repository to Workers Builds

  1. Follow Connect a new Worker to connect your GitHub repository to Workers Builds.
  2. Set the Build command for your site:
    • Jekyll: bundle exec jekyll build
    • Plain HTML: Leave blank
    • Other static site generators: Your framework build command (for example, npm run build or hugo)
  3. Keep the default Deploy command (npx wrangler deploy) and select Save and Deploy.

After the initial build completes, every push to your production branch deploys automatically, and pull requests receive Preview URLs.

4. Migrate your custom domain

Workers Custom Domains support domains whose DNS is managed by Cloudflare.

  1. Verify your deployed site on its *.workers.dev subdomain.
  2. In your GitHub repository settings under Pages, remove the custom domain so GitHub no longer serves it.
  3. In the Cloudflare dashboard under DNS > Records, remove the CNAME or A records pointing to <your-username>.github.io or GitHub Pages IP addresses.
  4. Follow Add a Custom Domain to attach your domain to your Worker.

Was this helpful?