# Local sites (WP Studio, LocalWP)

> Build the site in WP Studio or LocalWP on your computer and publish only the static copy.

<!-- Sources: docs/static-export.md (Local environments); src/StaticExport/Fetch/PageFetcher.php; src/StaticExport/Deploy/SecretBox.php -->

# Local sites (WP Studio, LocalWP)

:::caution Beta
Static Export is in beta. See [what Beta means](./overview.mdx#what-beta-means).
:::

The recommended way to use Static Export is to keep WordPress on your own computer and publish only the static copy. Your WordPress site then never has to be reachable from the internet, and visitors only ever reach static files. This page lists what to know for the two supported local tools.

## How it works on a local site

The export reads your pages from the site itself, so the site does not need a public address. Deployments connect from your computer to Cloudflare, so your computer needs internet access while you deploy.

**Connect with Cloudflare** works on local sites without HTTPS. Sites on `localhost`, `*.localhost`, `*.local`, `*.test`, `127.0.0.1` or a private network address may use plain `http://`. The page on `connect.ohmyetch.com` then notes that it is a local site. Only your browser goes back to the local address, so the site does not need to be reachable from the internet. See [Connect with Cloudflare](./deploy-cloudflare.mdx#connect-with-cloudflare).

The usual cycle:

1. Edit the site in WordPress on your computer.
2. [Export it](./export-a-site.mdx). Its facet filters are recorded with it.
3. Deploy to [Cloudflare](./deploy-cloudflare.mdx), or [download the ZIP](./export-a-site.mdx#download-the-zip) and upload it to your static host.

## WP Studio

WP Studio is supported, including its SQLite database.

WP Studio's `wp-config.php` defines no security keys and salts, so WordPress keeps them in the database. When you paste a token or use **Connect with Cloudflare**, the panel warns that the saved token is weakly protected. To remove the warning, define `OME_STATIC_EXPORT_SECRET_KEY` in the site's `wp-config.php` and enter the token again (or connect again), or define the token itself there. See [The encryption key](./keeping-tokens-safe.mdx#the-encryption-key).

To run the [WP-CLI commands](./wp-cli.mdx), use Studio's own command line from a terminal: `studio wp --path <site folder> oh-my-etch static-export run`.

## LocalWP

LocalWP is supported and behaves like a normal server, so there is nothing special to set up.

To run the [WP-CLI commands](./wp-cli.mdx), open the site in Local and choose **Open Site Shell**, then run them there.

## Local sites with a custom HTTPS domain

Sites served on a custom local domain over HTTPS with a self-signed certificate (LocalWP's site domains router mode, or WP Studio with a custom domain and HTTPS) have not been tested yet. They are expected to work: the export only fetches pages from your own site and, like WordPress's own requests to itself, does not check the certificate for them. If you meet a problem there, please report it.

## When the site cannot reach itself

The export fetches pages from the site's own address. If the server cannot reach that address, for example because WordPress runs in a container, the export tries `127.0.0.1` on the same port, then on port 80. When none of these works, define the address the server can use in `wp-config.php`:

```php
define( 'OME_STATIC_EXPORT_LOOPBACK_URL', 'http://wordpress' );
```

The value is an address with `http://` or `https://` and an optional port, without a path. When it is defined, the export tries it first. If none of the addresses answers, the **Problems** table of the export shows the note `No connection base answered: …`.

:::note For plugin developers using wp-env
In wp-env, the `cli` container cannot reach the site on its own address. Define `OME_STATIC_EXPORT_LOOPBACK_URL` as `http://wordpress` for WP-CLI exports, for example through `wp --require=<file>`.
:::
