# Static prerender

Bake the blog into static HTML files at build time. Ideal for static hosts
(GitHub Pages, S3, plain nginx) and for CI/CD pipelines that redeploy on a
schedule.

```
npx baas-blog prerender --key pk_YOUR_KEY --api https://api.dailysmith.com --out ./public/blog
```

This writes:

:::tree

- public/
  - blog/
    - index.html
    - your-first-post-slug/
      - index.html
    - another-post-slug/
      - index.html

:::

Deploy the output with the rest of your site and the blog is fully
crawlable with zero runtime dependencies.

## Options

| Flag | Default | Meaning |
|---|---|---|
| `--key` | — | Your site's public key (`pk_…`), required |
| `--out` | `./public/blog` | Output directory |
| `--api` | `https://api.blogsaas.app` | API origin serving your content |
| `--base` | `/blog` | The base path the blog is mounted at |

:::callout{severity=warning title="Always pass --api explicitly"}
The CLI's built-in default points at the hosted production API — it does
**not** infer your deployment's origin. If you're running this docs site
locally or self-hosting, an omitted `--api` silently prerenders from
`https://api.blogsaas.app` instead of `https://api.dailysmith.com`. Always pass
`--api https://api.dailysmith.com` explicitly.
:::

## Keeping it fresh

Static output is a snapshot. Re-run the prerender:

- on every deploy, and
- on a schedule (e.g. a daily CI cron) so scheduled posts appear without a
  manual deploy.

## Taking a post down

A run also **removes** the pages of posts that are no longer published, so a
post you take down in the dashboard disappears from the static output on the
next prerender. Deleting it is only possible because the CLI keeps a
manifest of what it wrote — `.baas-prerender.json`, in the output directory —
and deletes nothing it did not put there itself.

Keep that file next to the output between runs (or let CI build into a fresh
directory, where there is nothing stale to remove in the first place). If you
delete the manifest but keep the HTML, a taken-down post's page stays on
disk until you remove it by hand.

:::callout{severity=info title="Add the SDK on top"}
Prerendered pages work standalone, but including the
[JS SDK](/docs/install-sdk) snippet in your page shell upgrades navigation
to instant client-side loads — and shows posts published since the last
deploy.
:::
