WP-CLI and configuration reference
Static Export is in beta. Its commands, constants and filters may change between releases. See what Beta means.
Everything the panel does, except recording filters, can also be done from a terminal with WP-CLI. This page lists every command, then the constants and filters that change how Static Export behaves.
Run the commands in the WordPress folder of your site, as you run any wp command. On LocalWP, use Open Site Shell; see Local sites.
Every command exits with 0 when it succeeded and with a non-zero status when it was refused, failed or was cancelled, so you can use them in scripts.
Export then deploy
A complete run, from switching the feature on to a live site:
# Once: switch Static Export on.
wp oh-my-etch static-export enable
# Export the site for the root of a domain, as a workers.dev address is.
wp oh-my-etch static-export run
# Deploy it. The connection comes from the panel or wp-config.php.
wp oh-my-etch static-export deploy cloudflare --name=my-site
# Check the result.
wp oh-my-etch static-export deploy status
To host the site somewhere else, export it as a ZIP file with the matching target base, for example for a GitHub Pages project site at https://octo-org.github.io/my-site/:
wp oh-my-etch static-export run --target-base=/my-site --zip=./site.zip
Deploying to GitHub Pages with deploy github is a preview that is switched off in this version; see deploy github.
An export made with WP-CLI does not record facet filters, because recording runs in a browser: each list shows its first page, with its filters hidden. To publish a site with working filters, export it in the Static Export panel with Export site, which records them by itself. Then deploy from the panel or with deploy cloudflare.
Export commands
enable
Turns Static Export on.
wp oh-my-etch static-export enable
disable
Turns Static Export off.
wp oh-my-etch static-export disable
Unlike the panel, disable does not ask for confirmation. It deletes the export stored on the site, the saved GitHub and Cloudflare tokens and the chosen repository, branch and Worker name, and stops an export or deployment that is running. A connection made with Connect with Cloudflare is also ended at Cloudflare, as Disconnect does. Nothing else on GitHub or Cloudflare is deleted.
run
Exports the site and runs the export to the end, printing progress.
wp oh-my-etch static-export run [--target-base=<base>] [--output=<dir>] [--zip=<file>] [--force]
| Option | Meaning |
|---|---|
--target-base=<base> | The site address on the static host: a path such as /docs, or a full http(s) address, without a trailing slash. Leave it out when the site is served from the root of a domain. See Choose the site address. |
--output=<dir> | Also copy the finished site into this folder. The folder must not exist yet or must be empty, and its parent folder must exist. |
--zip=<file> | Also write the finished site as a ZIP file here. The file must not exist yet, and its folder must exist. |
--force | Cancel an export that is already running instead of refusing to start. It never empties --output. |
Examples:
# Export into a new folder.
wp oh-my-etch static-export run --output=./static-site
# Export for a host that serves the site under /docs, as a ZIP file.
wp oh-my-etch static-export run --target-base=/docs --zip=./site.zip
At the end it prints Exported … URLs into … files (…)., then one warning per problem, then what was left out and what will not work:
Left out on purpose (woocommerce): 12 URLs, such as /shop/, /cart/.
Will not work on a static host (form): 3 pages, such as /contact/.
The words in brackets are the same reasons and notices the panel lists under Left out of the export and Works differently on a static host; see Read the summary.
With or without --output and --zip, the export also stays on the site, ready for a deployment or for Download ZIP in the panel.
status
Shows the status of the current or last export.
wp oh-my-etch static-export status [--format=<format>]
| Option | Meaning |
|---|---|
--format=<format> | table (default) or json. JSON prints the whole status, including every listed problem. |
wp oh-my-etch static-export status --format=json
cancel
Cancels the running export.
wp oh-my-etch static-export cancel
Deploy commands
Deploy commands publish the last finished export. There is no --token option: tokens are never passed on the command line. Connect a token in the panel, or define it in wp-config.php (see Constants).
There is no sign-in from the command line. deploy cloudflare uses a connection made with Connect with Cloudflare in the panel, and renews its token by itself.
deploy github
deploy github is a preview that is switched off in this version. It then exits with a non-zero status and prints GitHub Pages deployment is not available in this version yet., before it reads any token or checks anything else. It works only while OME_STATIC_EXPORT_GITHUB_PREVIEW is defined as true in wp-config.php; see Deploy to GitHub Pages (preview) and Constants. The rest of this section describes the preview.
Commits the export to a GitHub Pages branch, sending only the files the branch does not have yet. Then it switches GitHub Pages on for that branch when it is off and waits for Pages to publish. It prints the address when the commit is on the branch, with a warning when Pages has not published it yet. Nothing on GitHub is ever deleted, and a branch is never force-pushed.
wp oh-my-etch static-export deploy github [--repo=<repository>] [--branch=<branch>] [--overwrite[=<sha>]]
| Option | Meaning |
|---|---|
--repo=<repository> | The repository, as owner/repository. It is remembered, as in the panel. Defaults to the repository chosen before. |
--branch=<branch> | The branch to publish. It is remembered, as in the panel. Defaults to the branch chosen before, else gh-pages. |
--overwrite=<sha> | Replace the files on a branch whose last commit this site did not make, but only while that last commit is <sha>: the 40-character commit the refusal printed. The branch's history is kept. Without it, or when the branch has moved since, such a branch is left alone. A bare --overwrite without a commit is refused. |
Examples:
# First deployment to a repository.
wp oh-my-etch static-export deploy github --repo=octo-org/my-site
# The branch "site" holds commits from elsewhere: replace its files after checking the commit.
wp oh-my-etch static-export deploy github --branch=site --overwrite=0123456789abcdef0123456789abcdef01234567
When the branch holds commits from elsewhere, the command stops and prints the branch's last commit with the advice Choose another branch with --branch, or run again with --overwrite=<sha> to replace the files on that branch; its history is kept. When the branch already holds exactly this export, it says The branch … already holds this export, so nothing was committed.
A command-line deployment allows longer requests than the browser, so it can finish deployments with large files that are slow from the panel.
deploy cloudflare
Uploads the files Cloudflare does not have yet, publishes the Worker and turns on its workers.dev address. It prints the address when the site is live.
wp oh-my-etch static-export deploy cloudflare [--name=<worker>] [--overwrite]
| Option | Meaning |
|---|---|
--name=<worker> | The Worker to deploy to: 1 to 63 lower-case letters, digits and dashes. It is remembered, as in the panel. Defaults to the name chosen before, else one made from the site's host. |
--overwrite | Replace a Worker of that name that this site did not deploy. Without it, such a Worker is left alone and the command stops. |
Examples:
wp oh-my-etch static-export deploy cloudflare
wp oh-my-etch static-export deploy cloudflare --name=my-site
deploy status
Shows the current or last deployment: a Cloudflare row, and the GitHub deployment once GitHub was used. It covers a GitHub deployment also while the GitHub Pages preview is off.
wp oh-my-etch static-export deploy status [--format=<format>]
| Option | Meaning |
|---|---|
--format=<format> | table (default) or json. In JSON, every item names its provider. |
wp oh-my-etch static-export deploy status --format=json
deploy cancel
Cancels the running deployment, on Cloudflare or GitHub, also while the GitHub Pages preview is off. The Worker on Cloudflare and everything on GitHub are left as they are. It exits with 1 when a deployment could not be cancelled and is still running.
wp oh-my-etch static-export deploy cancel
Only one export or deployment runs at a time, whether it was started in the panel or from WP-CLI.
Constants
Define these in wp-config.php. The three token constants can also be set as environment variables with the same names.
| Constant | Meaning |
|---|---|
OME_STATIC_EXPORT_GITHUB_PREVIEW | Turns on the GitHub Pages preview, which is off in this version, when defined as exactly true. Only the constant counts: an environment variable does not turn it on. See Deploy to GitHub Pages (preview). |
OME_STATIC_EXPORT_GITHUB_TOKEN | The GitHub token used for deployments with the GitHub Pages preview. It never enters the database, and the panel cannot change it. |
OME_STATIC_EXPORT_CLOUDFLARE_API_TOKEN | The Cloudflare API token used for deployments. Same as above. While it is defined, the panel does not offer Connect with Cloudflare. |
OME_STATIC_EXPORT_CLOUDFLARE_ACCOUNT_ID | The Cloudflare account ID, 32 hexadecimal characters. Needed together with the token constant. |
OME_STATIC_EXPORT_SECRET_KEY | The key that encrypts tokens pasted into the panel and the tokens of a Cloudflare sign-in: a random string of at least 32 characters. Without it, the WordPress salts are used. See The encryption key. |
OME_STATIC_EXPORT_LOOPBACK_URL | The address the server uses to fetch its own pages, such as http://wordpress, when it cannot reach the site's public address. See When the site cannot reach itself. |
OME_STATIC_EXPORT_DIR | An absolute folder path where the site keeps its export, instead of the ome-static-export folder inside the uploads folder. |
Filters
These filters are for developers and, like the rest of Static Export, may change while it is in beta. Add them in a small plugin or your theme's functions.php.
| Filter | Default | Meaning |
|---|---|---|
ome_static_export_max_urls | 50000 | The most addresses one export may collect before it stops with an error. |
ome_static_export_seed_urls | WordPress's sitemap entries | The list of absolute addresses the export starts from, for one sitemap page at a time. Return a list of strings to add or remove addresses. |
ome_static_export_fetch_timeout | 20 | Seconds to wait for one page or file. |
ome_static_export_max_response_bytes | 52428800 (50 MB) | The largest page or file the export accepts, in bytes. |
ome_static_export_facet_snapshot_budget | 500 | The most filter combinations one list recorded as Facet Snapshots may need before it counts as over the limit. At most 100000. |
ome_static_export_max_facet_snapshots | 20000 | The most recorded filter results one export may hold. |
ome_static_export_max_facet_snapshot_bytes | 314572800 (300 MB) | The most bytes of recorded filter results one export may hold, Composed Datasets included. |
ome_static_export_max_facet_composed_bytes | 52428800 (50 MiB) | The most bytes of one list's Composed Dataset. A list over it is recorded as Facet Snapshots. |
ome_static_export_max_facet_composed_dataset_bytes | 8388608 (8 MiB) | The most bytes of the main file of one Composed Dataset, its item files not counted. A list over it is recorded as Facet Snapshots. |
ome_static_export_max_facet_composed_search_bytes | 8388608 (8 MiB) | The most bytes of the search file of one Composed Dataset; it counts toward the dataset's limit too. A list over it keeps its filters without text search. |
ome_static_export_composed_language_supported | false on a site with WPML or Polylang, else true for the site's own language or none | Whether a list requested in a language can be recorded with Composed Filters. Receives the decision and the request language. |
For example, to raise the per-list limit:
add_filter( 'ome_static_export_facet_snapshot_budget', static fn (): int => 2000 );
With All filters, this limit applies only to lists that are not recorded with Composed Filters: the panel records every such list within it with all its filters, and a list over it too, as long as the export can hold it; see Lists too large for one export.
The export also honours WordPress's own https_local_ssl_verify filter when it fetches your pages over HTTPS: by default it does not check the certificate of your own site.