Deploy to Cloudflare
Static Export is in beta. See what Beta means.
The Cloudflare destination of the Static Export panel exports your site and publishes that export as a Cloudflare Worker that serves static files (Workers static assets). The site is served at https://<worker>.<your-subdomain>.workers.dev. This page walks through connecting your account, the first deployment, and what happens on later ones.
Under Where should the site go?, choose Cloudflare. It is the recommended destination and is chosen when the panel opens. It has two numbered steps:
- Connect Cloudflare: connect your account. The step shows Done once deployments can use the connection.
- Deploy: choose the Worker name, test the connection and click Deploy to Cloudflare, which exports the site and deploys that export. Until Cloudflare is connected, this step says
Connect Cloudflare first, then deploy.
You can switch to another destination at any time. A sign-in or a deployment that is running goes on, and the Cloudflare destination is marked Deploying… while its deployment runs.
Before you start
Your Cloudflare account needs a workers.dev subdomain. If you have never used Workers, open Workers & Pages in the Cloudflare dashboard once and choose one. The plugin cannot create it for you.
There are three ways to connect:
- Connect with Cloudflare (recommended): you sign in to Cloudflare and approve. There is no token to create and no account ID to look up.
- Paste an API token: you create a token on Cloudflare yourself and paste it into the panel. The token can be limited more narrowly.
- Define the token in
wp-config.php: the most locked-down setup, because nothing is stored in the database.
Keeping tokens safe compares them.
Connect with Cloudflare
When step 1 reads Not connected, it shows the button Connect with Cloudflare and, under it:
Oh My Etch gets Workers Admin on the account you choose, so it can manage every Worker on it.
Cloudflare opens in a new tab, where you choose the account to deploy to. Oh My Etch then gets permission to deploy and manage Workers on that account, which Cloudflare lists as Workers Admin. That covers every Worker of the account, not only this site's. A pasted API token can be limited more narrowly.
- Click Connect with Cloudflare. Cloudflare opens in a new tab. The panel shows Waiting for Cloudflare… and
Finish the sign-in in the Cloudflare tab.The section updates by itself when you are done. - In the Cloudflare tab, sign in if asked, choose the account to deploy to, and approve.
- Cloudflare then sends you to a page on
connect.ohmyetch.comtitled Finish connecting Cloudflare to this WordPress site? It shows the address of the WordPress site it will continue to. Check that this is your own site, then click Continue to … (your site's address). - Your site finishes the connection and says
Cloudflare is connected. You can close this tab and go back to Oh My Etch. - Close the tab. Back in the panel, step 1 reads Connected, shows the account's name and ID, and is marked Done.
The administrator who started the sign-in must finish it, in the same browser, within 10 minutes. If you closed the Cloudflare tab by mistake, use Open Cloudflare again under Waiting for Cloudflare…. Cancel stops waiting and cancels the sign-in. If the sign-in was already on its way back when you clicked Cancel, the panel shows Finishing the connection… until the site knows the result. If it then reads Connected and you do not want the connection, click Disconnect.
If you decline on Cloudflare, or the sign-in fails in the other tab, the panel goes back to Connect with Cloudflare within a few seconds and says that the sign-in was not finished. The page in the other tab says why.
What to check on the connect.ohmyetch.com page
Cloudflare only sends people back to one address that was registered in advance, while Oh My Etch runs on any domain. So Cloudflare sends you to connect.ohmyetch.com first, and that page hands the result on to your site.
- Continue only when the address shown is your own site and you started the sign-in from its WordPress admin a moment ago. Read the whole address, not only the domain name: when several sites share one domain, the part after it tells them apart. If you did not, close the page. Nothing is connected unless you continue.
- Names that only look like another name are shown in their technical form, starting with
xn--. If you see such a name and did not expect it, close the page.
The page sees a one-time code that cannot be used without a key that never leaves your site. It does not see any token, and it stores and logs nothing.
When you approved several accounts
If you chose more than one account on Cloudflare, your site says Cloudflare is connected. Close this tab and choose the account in the Static Export panel. Step 1 then reads Choose an account and lists the accounts. Select one and click Use this account. The site is deployed to the account you choose.
What the sign-in needs
- HTTPS. The site must be served over HTTPS. Local sites on
localhost,*.localhost,*.local,*.test,127.0.0.1or a private network address may use plainhttp://. Otherwise step 1 saysConnect with Cloudflare needs HTTPS. Paste an API token instead, or serve the site over HTTPS.and shows the token form instead of the button. - No token in
wp-config.php. WhenOME_STATIC_EXPORT_CLOUDFLARE_API_TOKENis defined, step 1 uses that token and does not offer the sign-in. - The connect.ohmyetch.com page must be up. The sign-in depends on it. A pasted token does not.
What the site stores
Cloudflare gives your site a token that works for one hour and a second token that lets the site get a new one. Both are stored encrypted, like a pasted token, and are never shown again. The site renews the first token by itself when a deployment or Test connection needs it. See What a sign-in stores.
Or paste an API token
Under Connect with Cloudflare, open Advanced: paste an API token. When the sign-in is not available on your site, the token form is shown directly.
Create the API token
- In the panel, under API token, follow the link Cloudflare's API token form. It opens the Cloudflare dashboard with a new token that already has the only permission needed: Account → Workers Scripts → Edit. You can also open the same form from here.
- Under Account Resources, limit the token to only the one account you deploy to.
- Create the token and copy it.
If the form opens empty, create a custom token under My Profile → API Tokens and give it that one permission yourself.
You also need the account ID. You find it on the Workers & Pages overview of the Cloudflare dashboard. It is 32 characters long.
The most secure setup is to put both in wp-config.php instead of pasting them into the panel, so the token never enters the database:
define( 'OME_STATIC_EXPORT_CLOUDFLARE_API_TOKEN', '…' );
define( 'OME_STATIC_EXPORT_CLOUDFLARE_ACCOUNT_ID', '0123456789abcdef0123456789abcdef' );
See Keeping tokens safe.
Connect with the token
If you defined both constants in wp-config.php, step 1 already reads Connected and shows the account ID. Skip to the next step.
Otherwise:
- Paste the token into API token.
- Enter the Account ID.
- Click Connect.
The status changes to Connected and shows the account ID. Saving only stores the token on this site, encrypted; it is not sent to Cloudflare yet and is never shown again. Replace token and Disconnect appear under it.
If you paste a token while step 1 reads Connection ended, the token replaces the sign-in. When Cloudflare cannot be reached to end that sign-in, the panel says The token is saved, but the earlier sign-in could not be ended: remove Oh My Etch under Connected Applications in your Cloudflare profile.
If the site was connected with Connect with Cloudflare, there is no Replace token. Click Disconnect first, then paste the token.
Choose the Worker name
The Worker name and Test connection are in step 2, Deploy. The Worker name decides the address: https://<worker>.<your-subdomain>.workers.dev. Leave the field empty to use the default, a name made from your site's host, which the field shows as its placeholder.
A Worker name is 1 to 63 lower-case letters, digits and dashes, and cannot start or end with a dash.
- Enter a name, or leave the field empty.
- Click Save name.
- Click Test connection.
The test asks Cloudflare whether the connection works and which workers.dev subdomain the account has. When it works, the panel says Connection works: the site will be served at … with the full address.
Deploy
In step 2, choose under Filters what to record of the facet lists, right above the button: All filters (the default), Pagination only or None. See Choose what is recorded. The choice applies when you click the button; changing it deploys and records nothing by itself.
Then click Deploy to Cloudflare. It runs three parts one after the other, and step 2 shows each while it runs:
- The export. Every click exports the site again, so the deployment always publishes the site as it is now. An export started here is always made for the root of a domain, because a
workers.devaddress is the root of its own domain, so there is no site address to enter. See Export a site. - Recording filters, when the site has facet lists, as chosen under Filters. With None, nothing is recorded and the deployment starts right after the export. See Facets: filters and lists.
- The deployment, which uploads that export to the Worker you named.
During the deployment the panel shows Deployment in progress, with the step it is on: checking files, Preparing the upload…, uploading files, Publishing the site…, then Turning on the address…. When Cloudflare asks to wait, the panel counts down and tries again by itself.
Keep this browser tab and the panel open until the deployment finishes. If you close either, the deployment pauses. Open the panel again and click Continue deployment, or Cancel deployment.
When it is done, the panel shows Deployed to Cloudflare, the address (The site is live at …), and how many files were uploaded and how many were already on Cloudflare. The summary of the export, Export finished, follows in the same step.
Nothing is deployed when the export fails or is cancelled, or when recording the filters is cancelled, stops or fails. A recording that could not record some lists still deploys. Step 2 then shows the result of the export, and when the site was deployed before, Last deployment, … with the address and the time of that earlier deployment: the new export is not live. Click Deploy to Cloudflare to try again.
An export that was paused, for example because the tab was closed, never deploys by itself. Continue export finishes it; click Deploy to Cloudflare afterwards to export and deploy.
The deployment turns on the Worker's workers.dev address and turns off its preview URLs. When your site has a 404 page, Cloudflare shows it for addresses that do not exist.
Later deployments
Click Deploy to Cloudflare again. It exports the site again and uploads only the files Cloudflare does not have yet; the result says how many were already there.
A Worker this site did not create
When a Worker with the chosen name already exists on the account and was not deployed from this site, the deployment stops and asks first:
Replace the Worker my-site? The Worker my-site already exists on this Cloudflare account and was not deployed from this site; deploying replaces it with this export.
- Replace it and deploy goes ahead and replaces that Worker.
- Keep the Worker stops. Nothing is deployed and the Worker stays as it is. The export that was just made stays. To deploy without replacing it, choose another Worker name.
Workers this site deployed carry a tag that identifies the site, so later deployments to them do not ask.
Plan limits
| Limit | Workers Free | Workers Paid |
|---|---|---|
| Files per Worker | 20,000 | 100,000 |
| Size of one file | 25 MiB | 25 MiB |
When the export has more than 20,000 files, the deployment warns that it needs the Workers Paid plan and goes ahead; Cloudflare refuses it if your account is on the Free plan. An export with more than 100,000 files, or with a file over 25 MiB, is refused before anything is uploaded.
Recorded filters add files. If an export is over the limit because of them, choose Pagination only or None under Filters, then click Deploy to Cloudflare again.
Cancel
Cancel deployment stops a running deployment. Nothing already live on Cloudflare is removed.
- If the request that publishes the site was already on its way, the site can still go live; the next deployment updates it without asking.
- A first deployment that is cancelled or fails part-way can leave an empty Worker with that name on your account. It serves nothing. The next deployment to the same name reuses it without asking. The plugin never deletes a Worker; delete it in the Cloudflare dashboard if you no longer want it.
Custom domain
The plugin publishes to the workers.dev address only. To serve the site on your own domain, add the domain to the Worker in the Cloudflare dashboard. An export from the Cloudflare destination is made for the root of a domain, which is what you need when the site is served at the root of that domain.
Deploy to Cloudflare always exports for the root first, so an export made under ZIP file with a site address never reaches the panel's deployment. The WP-CLI deploy cloudflare command publishes the last finished export instead, wherever it was started. An export made with a path, such as /docs, is then served under that path on workers.dev. An export made for a full address, such as https://example.com, is served at the root but its links still point to that address; the deployment warns about it.
Disconnect
Disconnect asks first, then removes the connection from this site. A running deployment stops; nothing already live on Cloudflare is removed. A token in wp-config.php can only be removed there.
- Connected with Cloudflare: the site forgets the connection and asks Cloudflare to end it. If Cloudflare cannot be reached, the panel says:
This site is disconnected, but Cloudflare could not be reached: remove Oh My Etch under Connected Applications in your Cloudflare profile.To do that, open your profile in the Cloudflare dashboard and go to Connected Applications. - Pasted token: the token is deleted from this site. Delete it in the Cloudflare dashboard as well when you no longer need it.
To deploy again, connect again. Turning Static Export off does the same as Disconnect.
Connection ended
A connection made with Connect with Cloudflare can be ended by Cloudflare. Step 1 then reads Connection ended:
Cloudflare ended this connection: connect again to deploy.
Click Connect with Cloudflare to connect again.
The usual cause is a copy of the site, such as a staging site made from a copy of the production database. It can also happen after a long time without deploying. Both copies then hold the same connection. Cloudflare lets the site use each renewal only once, so when both copies deploy, Cloudflare ends the connection for both. To avoid it, connect each copy on its own after copying, so each gets its own connection, or use a pasted API token on the copy.
To deploy from a terminal, see wp oh-my-etch static-export deploy cloudflare.