# Vitrine > A Hugo theme for documentation, with examples that run on the page next to their code. ## A live example The walk below runs on this page. Under it are the files it's made of, exactly as they run: no build step, and no second copy of the code to keep in sync. {{< example name="walk" title="A random walk" >}} ## What you get **Examples that run.** A folder with `example.html`, and optionally `style.css` and `script.js`, becomes a live demo with its files in tabs below it. Its CSS is scoped to the example, its script runs as a module, and an import map lets the script import a library by its npm name. See [Live examples](/docs/examples/). **Navigation.** Tabs across the top for the site's sections, a two-level sidebar for the section you're in, "On this page" on the right, previous and next at the bottom. See [Pages and navigation](/docs/writing/pages-and-navigation/). **Docs for AI assistants.** `llms.txt`, `llms-full.txt` and a Markdown copy of every page, with no setup. See [llms.txt](/docs/reference/llms-txt/). **Small.** Plain CSS and one small script, no framework and no Node build. Hugo does everything. --- # Docs > How to build documentation with Vitrine, from installing it to examples that run on the page. Vitrine is a theme for [Hugo](https://gohugo.io/), the static site generator. You write pages in Markdown, Hugo turns them into a website, and Vitrine decides how that website looks and works: the tabs, the sidebar, code blocks, live examples and the rest. These docs are built with Vitrine itself. If you're new, start with [Getting started](getting-started/). The [reference](reference/) lists every setting, front matter key and shortcode in one place. --- # Getting started > From an empty folder to a running docs site. Two steps: [install](installation/) Hugo and the theme, then [write your first pages](first-pages/). If you already have a Hugo site, skip to the part of the installation that adds the theme. --- # Writing > Pages, navigation, and what Markdown can do in Vitrine. Vitrine reads ordinary Markdown. These chapters cover how pages become navigation, what each Markdown element looks like, and the two shortcodes for writing: tabs and callouts. --- # Markdown > Headings, links, code blocks, tables and images, and what Vitrine adds to each. Vitrine uses Hugo's Markdown (CommonMark with GitHub's extensions: tables, task lists, strikethrough). A few elements get extra behaviour through Hugo's render hooks. ## Headings Start a page's chapters at `##`; the page's title is its `#`. Every `##` starts at a thin rule. Headings get a `#` link to themselves, shown on hover, so readers can link to a chapter. `##` and `###` headings are listed in "On this page". ## Links ```md [Installation](/docs/getting-started/installation/) [a chapter on this page](#code-blocks) [the config file](hugo.toml) [Hugo](https://gohugo.io/) ``` - A link to a page, written as its path in `content/`, becomes that page's address. It works with or without the trailing slash, and keeps working if your site lives under a subpath like `example.org/docs/`. - A link to a file next to the page (in its page bundle) becomes the file's address. - A path from the site's root to a file in `static/` gets the site's base path. - A link to another site opens in a new tab, and screen readers hear "opens in a new tab". ## Code blocks Fenced code gets a head with its language and a copy button: ```js const answer = 42; ``` Name the file instead of the language with `file`: ````md ```js {file="script.js"} const answer = 42; ``` --- # Tabs and callouts > Two shortcodes for writing: the same thing in several variants, and a note or warning beside the text. ## Tabs Use tabs for the same content in variants: package managers, operating systems, languages. ```md {{}} {{}} ```sh npm install my-lib ``` {{}} {{}} ```sh pnpm add my-lib ``` {{}} {{}} ``` (Without the indentation: it's only there to show the code fences inside.) {{< tabs group="install" >}} {{< tab "npm" >}} ```sh npm install my-lib ``` {{< /tab >}} {{< tab "pnpm" >}} ```sh pnpm add my-lib ``` {{< /tab >}} {{< tab "yarn" >}} ```sh yarn add my-lib ``` {{< /tab >}} {{< /tabs >}} --- # Maths > Formulas with MathJax, on the pages that ask for it. ## Turning it on Markdown would read the backslashes in `\(` and `\[` as escapes and drop them before MathJax sees the formula. Hugo's passthrough extension leaves formulas untouched; add it to your `hugo.toml` once: ```toml {file="hugo.toml"} [markup.goldmark.extensions.passthrough] enable = true [markup.goldmark.extensions.passthrough.delimiters] block = [['\[', '\]'], ['$$', '$$']] inline = [['\(', '\)']] ``` Then add `math: true` to a page's front matter, or turn it on for every page: ```toml {file="hugo.toml"} [params] math = true ``` A page can then turn it off with `math: false`. MathJax 4 loads only on pages with maths turned on. ## Writing formulas In-line maths goes between `\(` and `\)`, display maths between `$$` lines (or `\[` and `\]`): ```md The identity \(e^{i\pi} + 1 = 0\) and the integral $$ \int_0^1 x^2 \, dx = \frac{1}{3} $$ ``` The identity \(e^{i\pi} + 1 = 0\) and the integral $$ \int_0^1 x^2 \, dx = \frac{1}{3} --- # Live examples > Examples that run on the page, with their files shown below them exactly as they run. The `example` shortcode is what Vitrine is named after: a glass case with the real thing inside. A folder of up to three files becomes a running demo, and the same files, unchanged, appear in tabs below it. What readers copy is what ran. Start with [the example shortcode](example-shortcode/), then read how [styles, scripts and imports](styles-and-scripts/) stay inside their example and load libraries. --- # Reference > Every setting, front matter key and shortcode in one place. Look things up here; the chapters before explain them with examples. --- # Front matter > The keys Vitrine reads at the top of a page, and the start page's own. ## Every page | Key | What it does | |---|---| | `title` | the page's heading, its name in the browser tab and, unless `linkTitle` is set, in the sidebar, breadcrumbs and pager | | `linkTitle` | a shorter name for the sidebar, breadcrumbs, pager and tabs | | `weight` | the order among its siblings: lower first; pages without one come last | | `lead` | the line under the title, in Markdown; also the page's description and its summary in lists and llms.txt | | `description` | the description for search engines and link previews, if it should differ from `lead` | | `math` | `true` loads MathJax for this page, `false` keeps it off when `params.math` is on | | `draft` | `true` keeps the page out of the built site; `hugo server -D` shows it | Hugo's own keys work as usual: `date`, `slug`, `url`, `aliases` (old addresses that redirect to the page) and `build` (for example `build: { list: never }` to keep a page out of the sidebar). ```yaml --- title: Configuration reference linkTitle: Configuration weight: 1 lead: Every setting, with its default. --- ``` ## The start page `content/_index.md` also reads: | Key | What it does | |---|---| | `facts` | short labels in a row under the lead: `["4 kB gzip", "MIT"]` | | `install` | a command in a code block with a copy button: `npm install my-lib` | | `actions` | buttons: a list of `{ label, url }`; the first is filled. A `url` from your site is relative to its root (`docs/`), others are full addresses | ```yaml --- title: my-lib lead: What it does, in one or two sentences. --- # Shortcodes > The shortcodes Vitrine adds, and their options. ## example Runs an example and shows its files. [The example shortcode](/docs/examples/example-shortcode/) explains it. ```md {{}} {{}} ``` | Option | Default | | |---|---|---| | `name` (or the only positional value) | none | the folder with `example.html`, `style.css`, `script.js`: next to the page, or in `assets/examples/` | | `title` | none | a title in the frame's label | | `run` | `true` | `false`: show only the files | | `code` | `true` | `false`: run without showing the files | | `frame` | `true` | `false`: run bare, no frame and no files | ## tabs and tab Content in variants, one shown at a time. [Tabs and callouts](/docs/writing/tabs-and-callouts/) has examples. ```md {{}} {{}}Markdown{{}} {{}}Markdown{{}} {{}} ``` | Option | Default | | |---|---|---| | `tabs`: `group` | none | tab sets of the same group switch together, and the choice is remembered | | `tab`: the positional value | none | the tab's label | ## callout A note or a warning, in Markdown. ```md --- # llms.txt > Your docs as plain Markdown for AI assistants, generated with every build. ## What Vitrine publishes With every build, Vitrine writes three kinds of files next to your pages: | File | What it holds | |---|---| | `/llms.txt` | your site's title and description, then a list per section of its pages, each with its lead and a link to its Markdown copy, in the sidebar's order: the format proposed at [llmstxt.org](https://llmstxt.org/) | | `/llms-full.txt` | every page's Markdown in one file, in the same order | | `//index.md` | each page's title, lead and Markdown source | Every page also names its Markdown copy in its head: ```html ``` See this site's [llms.txt](/llms.txt) and [llms-full.txt](/llms-full.txt). ## Using them Point your assistant at the file that fits: - **llms.txt** when it can follow links: it reads the list and fetches the pages it needs. - **llms-full.txt** when you paste or attach the whole documentation, or for a tool that reads a single address. - **A page's `index.md`** for one topic. Shortcodes appear in the Markdown as you wrote them (`{{}}`, `{{}}`). Assistants read them well enough, but an example's files aren't in the Markdown copy; describe what an example shows in the page's text. ## Turning them off ```toml {file="hugo.toml"} [params] llms = false ``` --- # Guides > Making Vitrine your own, putting the site online, and what's planned. How to change the look and the templates without forking the theme, how to deploy, and the features that aren't in Vitrine yet. --- # Deployment > Building the site and putting it online, with GitHub Pages as the example. ## Building ```sh hugo --minify ``` writes the site to `public/`: plain HTML, CSS and JavaScript that any web server can serve. Set `baseURL` in `hugo.toml` to the address the site will have, including a subpath if it has one (`https://you.github.io/my-lib/`). ## GitHub Pages In your repository's settings, under **Pages**, set the source to **GitHub Actions**. Then add this workflow. It installs Hugo and Go (for the theme as a Hugo module), builds the site and publishes it on every push to `main`: ```yaml {file=".github/workflows/pages.yml"} name: Pages on: push: branches: [main] workflow_dispatch: permissions: contents: read pages: write id-token: write concurrency: group: pages cancel-in-progress: false jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: --- # Roadmap > What Vitrine doesn't do yet, and might, if people need it. Vitrine 1.0 does what its own docs and a small library's docs need. These are left out on purpose for now; open an [issue](https://github.com/maxfettinger/vitrine/issues) if you need one, and say what for. | Feature | Notes | |---|---| | Search | most likely with [Pagefind](https://pagefind.app/), which indexes the built site and needs no server | | Translations | the theme's own words ("On this page", "Previous", "Edit this page") are English; Hugo's i18n files would make them translatable, and multilingual sites possible | | A third sidebar level | the sidebar shows two levels | | Versioned docs | one site per version works today, with a link between them; a version menu is not built in | | Last updated dates | from Git (`enableGitInfo`), under each page | | An announcement banner | today: the body-end hook | | Diagrams | Mermaid, as a code block render hook | | "Copy page" button | the page's Markdown copy to the clipboard, for pasting into an assistant | Already there but easy to miss: [llms.txt](/docs/reference/llms-txt/), [maths](/docs/writing/maths/), [hooks and your own CSS](/docs/guides/customizing/). --- # Examples > Small examples running on the page, each with exactly the files it's made of. Each page here runs one example made with the [example shortcode](/docs/examples/example-shortcode/). The files in the tabs are the files that run.