static_

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

  1. Create an API token with the Cloudflare Pages: Edit permission and note your account ID.

  2. Put them in .env.local in the project (keep this file out of git):

    CLOUDFLARE_API_TOKEN=...
    CLOUDFLARE_ACCOUNT_ID=...
    
  3. Create the Pages project once:

    npx wrangler pages project create my-pages-project --production-branch=main
    
  4. static deploy --prod publishes to the production branch; static deploy publishes 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:

  1. Put the project in a GitHub repository and push it.
  2. Add the secrets the workflow lists as repository secrets (CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID, or the Netlify equivalents), and a SITE_URL repository variable holding your production URL.
  3. 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/static line to edit, or pass --cli=<npm install spec> to static 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.