Start from existing
Workers Sites require Wrangler — make sure to use the latest version .
To deploy a pre-existing static site project, start with a pre-generated site. Workers Sites works well with all static site generators. For a quick-start, review the following projects:
- Hugo
- Gatsby, requires Node
- Jekyll, requires Ruby
- Eleventy, requires Node
- WordPress (refer to the tutorial on deploying static WordPress sites with Workers )
After you have generated a site, follow these steps:
- Run this Wrangler command in the root of your project’s directory:
$ wrangler init --site my-static-site
This command creates a few things: a wrangler.toml
file and a workers-site
directory.
- Add your site’s build directory to the
wrangler.toml
file:
[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
to your wrangler.toml
. You can find your account_id
by logging into the Cloudflare dashboard Account Home > choose your website > Overview > Account ID For more details on finding your account_id
, refer to the
Gett started guide
.
- You can preview your site by running:
$ wrangler dev
- Decide if you would like to publish your site to a
*.workers.dev
subdomain or a custom domain that you own and have already attached as a Cloudflare zone.
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.
Learn more about configuring your project .
- Run:
$ wrangler publish