Start from an Existing Site

Worker Sites require Wrangler - make sure to be on the latest version - and the Workers Unlimited plan.

To deploy a pre-existing static site project, you’ll need to start with a pre-generated site. Workers Sites works well with all static site generators! For a quick-start, check out the following projects:

Once you have a site generated, follow these steps:

  1. Run this Wrangler command in the root of your project’s directory:

    $ wrangler init --site my-static-site
    

    This command creates a few things: wrangler.toml and aworkers-site directory.

  2. Add your site’s build directory to the wrangler.toml:

    [site]
    bucket = "./public" # <-- Add your build directory name here!
    entry-point = "workers-site"
    

    The default directories for the most popular static site generators are listed below:

    • Hugo: public
    • Gatsby: public
    • Jekyll: _site
    • Eleventy: _site
  3. Add your account_id your wrangler.toml. You can find your account_id on the right sidebar of the Workers or Overview Dashboard. Note: You may need to scroll down! For more details on finding your account_id click here.

  4. You can preview your site by running:

    wrangler preview --watch
    
  5. Decide where you’d like to publish your site to: a workers.dev subdomain or your personal domain registered with Cloudflare. Then, update your wrangler.toml:

    • Personal Domain: Add your zone_id and a route.
    zone_id = "42ef.."
    route = "example.com/*"
    
    • workers.dev: Set workers_dev to true. This is the default.

    You can learn more about configuring your project here.

  6. Run:

    wrangler publish