# Build a docs site

```sh
elysium build docs -o site
```

That reads every `.md` file under `docs/` and writes a finished site to
`site/`. Every page gets:

- a sidebar, previous and next links, and an "On this page" list
- an anchor link on every `h2` and `h3`
- links between pages by file path, `[Install](install.md)`, or by wikilink, `[[Install]]`
- a Markdown copy at its URL plus `.md`, behind a "View as Markdown" button
- search over every section, run in the browser
- a "Last updated" date from git
- light and dark colors that follow the reader's system, see [Light and dark](labels.md#light-and-dark)
- a social card image, if you [ask for one](social-cards.md)

The site also gets `llms.txt`, `llms-full.txt` and, with a site URL,
`sitemap.xml`. A link to a missing page or heading fails the build.

`elysium build` built this site.

## Two ways to build

- **`elysium build`** writes a static site in Elysium's default theme. Nothing
  else to install.
- **The [Vite plugin](vite.md)** renders the pages inside your own Vite site,
  with your template, CSS and scripts.

Both run the same core, so pages read the same either way.

## Serve it

```sh
elysium build docs -o site --name "Acme Docs" --site-url https://acme.dev
elysium build docs -o public --base /docs
```

`-o` is the web root: with `--base /docs` the pages land in `public/docs/`.
Any static host that maps `/guide` to `/guide/index.html` serves it.

A rebuild deletes what the last build wrote and this one did not, such as a
removed page. It reads that list from `_elysium/files.json` and leaves every
other file in the output folder alone.

## elysium.json

Put options in `docs/elysium.json` instead of flags. Paths in it are relative to
the file:

```json
{
  "name": "Acme Docs",
  "siteUrl": "https://acme.dev",
  "sections": [
    { "title": "Start", "pages": ["", "install"] },
    { "title": "Guides", "pages": ["guides/deploy"] }
  ],
  "links": { "app:/": "https://app.acme.dev/" }
}
```

| Flag             | Key        | Default                                          |
| ---------------- | ---------- | ------------------------------------------------ |
| `-o, --out`      | `out`      | `site`                                           |
| `--name`         | `name`     | `Docs`                                           |
| `--base`         | `base`     | none                                             |
| `--site-url`     | `siteUrl`  | none                                             |
| `--template`     | `template` | `<dir>/_templates`, if there, else Elysium's own |
| `--assets`       | `assets`   | `<dir>/_assets`                                  |
| `--diagram-font` | `diagrams` | pele's default                                   |
| `--og`           | `og`       | no cards                                         |
| `--og-font`      | `og.fonts` | JetBrains Mono                                   |
| `--config`       |            | `<dir>/elysium.json`                             |
|                  | `sections` | one per folder                                   |
|                  | `links`    | `{}`                                             |
|                  | `icon`     | none                                             |
|                  | `font`     | JetBrains Mono                                   |
|                  | `lang`     | `en`                                             |
|                  | `labels`   | English                                          |
|                  | `contents` | `{ "minHeadings": 3 }`                           |

`--diagram-font Inter` is `"diagrams": { "fontFamily": "Inter" }` in the file.

- `sections` groups the sidebar and sets the order of previous and next. See
  [Write pages](pages.md#sections).
- `links` swaps a link prefix for another, so `[Open the app](app:/settings)`
  points at `https://app.acme.dev/settings`.
- `contents.minHeadings` is how many `h2`s a page needs before it gets an "On
  this page" list.
- `font` sets the family every page uses, and a stylesheet to link. See
  [Font](labels.md#font).
- `icon` is the URL of the favicon, such as `/favicon.svg` or a `data:` URL.
- `lang` and `labels` set the language; see [Labels and styles](labels.md).

## What it writes

| Path                              | Holds                          |
| --------------------------------- | ------------------------------ |
| `index.html`, `<page>/index.html` | each page                      |
| `index.md`, `<page>.md`           | each page's Markdown copy      |
| `search-index.json`               | the search index               |
| `llms.txt`, `llms-full.txt`       | page lists for language models |
| `sitemap.xml`                     | every page, with a site URL    |
| `<page>/og.png`                   | social cards, with `og`        |
| `_assets/`                        | the assets folder, as is       |
| `_elysium/`                       | the theme's CSS and script     |

Pages with math load KaTeX's CSS from jsDelivr.
