Deploying & CI
static build produces a plain folder, .build/, so any static host works. The static deploy command has built-in support for Cloudflare Pages and Netlify.
Choosing a target
In data/site.json:
{
"deploy": { "target": "cloudflare", "project": "my-pages-project", "productionBranch": "main" }
}
| key | meaning |
|---|---|
target | cloudflare or netlify (default netlify) |
project | Cloudflare Pages project name (required for Cloudflare) |
productionBranch | branch treated as production on Cloudflare (default main) |
Override once from the command line with --target=cloudflare.
static deploy # preview deploy
static deploy --prod # production
static deploy --strict # fail the deploy on any SEO warning
static deploy builds in production mode first and stops if the build fails, so a broken build is never published. Deploy tools are run with npx, so nothing needs installing globally.
Cloudflare Pages
Create an API token with the Cloudflare Pages: Edit permission and note your account ID.
Put them in
.env.localin the project (keep this file out of git):CLOUDFLARE_API_TOKEN=... CLOUDFLARE_ACCOUNT_ID=...Create the Pages project once:
npx wrangler pages project create my-pages-project --production-branch=mainstatic deploy --prodpublishes to the production branch;static deploypublishes a preview.
Environment files are loaded for the deploy command only. The tokens never reach the generated HTML.
Netlify
Link the project to a site once with netlify link (this stores the link in the project's .netlify/ folder). Then static deploy creates a draft deploy and static deploy --prod publishes it.
Deploy on every push (CI)
static ci
writes .github/workflows/deploy.yml. On each push to main the workflow installs the Static CLI, then runs static deploy <project> --prod. Steps to finish setup:
- Put the project in a GitHub repository and push it.
- Add the secrets the workflow lists as repository secrets (
CLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_ID, or the Netlify equivalents), and aSITE_URLrepository variable holding your production URL. - Make sure the workflow's install step points at wherever your copy of the Static CLI lives: the generated file contains a
npm install -g github:YOUR-USER/staticline to edit, or pass--cli=<npm install spec>tostatic ci.
With CI in place, posting a microblog note from any device is just a commit.
Headers, redirects and clean URLs
The build writes _headers (security headers and long-lived caching for fingerprinted assets) and _redirects (from site.redirects). Cloudflare Pages and Netlify both read these files. For cleanUrls: "extensionless" both hosts serve /about from about.html.