Deploy to Cloudflare
npx lectio-docs build leaves a fully static site in ./dist — every page
prerendered to HTML, with the search index at /search-index.json. Nothing
runs server-side, so Cloudflare can serve it as plain static assets.
The fast path — Wrangler and Pages
npx lectio-docs build # writes ./distnpx wrangler login # first time onlynpx wrangler pages deploy dist --project-name my-docs
The first deploy creates the Pages project and prints its URL —
https://my-docs.pages.dev. Every later run publishes a new version of the
same project, so "redeploy" is just build followed by deploy.
Unknown routes
Every page is prerendered, so real links resolve to real HTML files. For paths
that don't exist, the build also emits __spa-fallback.html — an app shell for
hosts that let you name a fallback document. On Cloudflare Pages that document
is 404.html, so copy it into place before deploying:
cp dist/__spa-fallback.html dist/404.html
Without a 404.html, Pages assumes a single-page app and answers unknown paths
with the home page's HTML instead.
Deploying from CI
The same command works headless with two environment variables: a
CLOUDFLARE_API_TOKEN (create one with the "Cloudflare Pages — Edit"
permission) and your CLOUDFLARE_ACCOUNT_ID.
npx lectio-docs buildcp dist/__spa-fallback.html dist/404.htmlnpx wrangler pages deploy dist --project-name my-docs
Alternatively, connect the repo in the Cloudflare dashboard (Workers & Pages →
Create → Pages) with npx lectio-docs build as the build command and dist as
the output directory, and every push deploys itself.
The Workers alternative
Cloudflare now steers new projects toward Workers with static assets. It's the
same static dist/, plus a small config at the repo root:
// wrangler.jsonc{"name": "my-docs","compatibility_date": "2026-08-02","assets": { "directory": "./dist", "not_found_handling": "404-page" }}
npx wrangler deploy
Pick this when you expect the site to grow server-side behavior later; for a plain docs site, Pages is the shorter road.
Custom domain
Either way, attach a domain in the dashboard under the project's Custom domains tab — Cloudflare handles the certificate and DNS record.