# web.site.generate

Write a static site into the project store

# web.site.generate

```
web.site.generate [--template TEXT] [--path TEXT] [--from TEXT] [--route TEXT] [--name TEXT] [--store TEXT] [--folder TEXT] [--version TEXT] [--latest] [--reference zebflow] [--on-conflict overwrite|skip|error] → site
```

Write a static site into the project store. One page: `--template pages/post.tsx --path posts/{{ input.slug }}.html` renders the TSX page with the payload as its `input` (`--route` sets `ctx.route`; default: the page's address). A docs site: `--from handbook` turns the Markdown under `docs/handbook/` into pages, a sidebar, a search index and, when the folder is served, a sitemap; `--template` is the page template, created from a scaffold when missing (default `docs.template.tsx`); `--name` is the site's name; each folder's `_meta.yaml` sets its title, `order` and `nav` (a page's front matter its `order`), and that one order drives the sidebar, prev/next and the search index; a page whose Markdown is gone is removed from the site on the next build. `--reference zebflow` adds the Zebflow reference: a page for every node (`nodes/<family>/<kind>`) and the worked examples (`examples/`), generated from this Zebflow at build time, never files in the repository; a node page lists the examples that use it, a node named in inline code anywhere on the site links to its page, and an authored page at a generated page's address is added to the bottom of it. A link to another page is written as that page's address. The site answers at its folder's place under the served folder (served `site`, docs written to `site/docs`: pages at `/docs/…`), at `/` until the folder is served. `--version 0.11` makes the build one version: written under `<folder>/0.11/` with its own assets and search index, never indexed, listed in `<folder>/versions.json`; with `--latest` it is also written at `<folder>/` — the unversioned address, the only one indexed, with the sitemap. A version once built is never rebuilt by a newer one: the template's switcher reads versions.json when the page loads. Both write under `--folder` (default `site` for a page, `docs` for a docs site), sharing one manifest and one `_assets/`; a page whose content changed is overwritten unless `--on-conflict` says skip or error, decided before anything is written. The page renders from the payload, which it also embeds for hydration — so it publishes what the payload holds — except the request: the trigger's `headers`, `cookies` and `auth` are never part of it; copy a value into a key of its own upstream to show it. Adds `site` and keeps the payload. The files stay private until the owner serves the folder in Studio → Files.

## Flags

- `--template`: The page template under the source root, ending .tsx, e.g. pages/post.tsx. Required for a page; for a docs site, created from a scaffold when missing (default: docs.template.tsx).
- `--path`: One page: its path inside the site folder, e.g. posts/{{ input.slug }}.html.
- `--from`: A docs site: the Markdown folder under docs/, e.g. handbook.
- `--route`: One page: ctx.route while rendering (default: the page's address on the site).
- `--name`: A docs site: its name (default: the folder's _meta.yaml title, else the folder name).
- `--store`: The project store to write to: `local`, or the id of an `s3` credential. Saved explicitly when the pipeline is registered (default: the project's default store at that moment)
- `--folder`: The site's folder in the store (default: site for a page, docs for a docs site). Every page of one site shares it, with one manifest and one _assets/.
- `--version`: A docs site: this build is one version, e.g. 0.11 — written under <folder>/0.11/ and listed in <folder>/versions.json.
- `--latest`: A docs site, with --version: the latest version, written again at <folder>/ — the unversioned address, the only one indexed.
- `--reference`: A docs site: zebflow adds a page for every node (nodes/<family>/<kind>) and the worked examples (examples/), generated from this Zebflow and linked both ways.
- `--on-conflict`: When the target already exists: overwrite, skip or error (default: overwrite)

## Examples

### Render one post to a static page

```
| web.site.generate --template pages/post.tsx --path "posts/{{ input.query.rows[0].slug }}.html" --route "/posts/{{ input.query.rows[0].slug }}"
```

It answers:

```json
{
  "site": {
    "mode": "page",
    "status": "written",
    "path": "site/posts/hello.html",
    "route": "/posts/hello",
    "template": "pages/post.tsx",
    "folder": "site",
    "store": "local",
    "manifest_path": "site/.zebflow-static-site.json",
    "file": {
      "__zf_type": "file_ref",
      "backend": "zebfs",
      "store": "local",
      "ref": "site/posts/hello.html",
      "filename": "hello.html",
      "mime": "text/html",
      "kind": "binary",
      "size": 5120,
      "sha256": "sha256:…",
      "lifecycle": "durable",
      "origin": "web.site.generate",
      "trust": "generated"
    }
  }
}
```

### Build the docs site nightly

```
| web.site.generate --from handbook --folder handbook-site --name "Example Handbook"
```

Markdown under `docs/handbook/` becomes HTML under `handbook-site/`, private until the owner serves that folder as a site in Studio → Files.

It answers:

```json
{
  "site": {
    "mode": "docs",
    "status": "ok",
    "name": "Example Handbook",
    "template": "docs.template.tsx",
    "from": "handbook",
    "folder": "handbook-site",
    "store": "local",
    "page_count": 12,
    "search_index_path": "handbook-site/search-index.json"
  }
}
```

### Publish the 0.11 docs as the latest version

```
| web.site.generate --from handbook --folder site/docs --version 0.11 --latest
```

With `site` served, the pages answer at `/docs/…` (latest) and `/docs/0.11/…` (pinned, not indexed); a later `--version 0.12 --latest` adds `/docs/0.12/` and leaves 0.11 as it was.

It answers:

```json
{
  "site": {
    "mode": "docs",
    "status": "ok",
    "name": "Handbook",
    "template": "docs.template.tsx",
    "from": "handbook",
    "folder": "site/docs",
    "store": "local",
    "page_count": 12,
    "version": "0.11",
    "latest": true,
    "versions_path": "site/docs/versions.json"
  }
}
```

## Used in

- [Static Entry Generation](/examples/static-entry-generation.md)
