Configuration
DocAnvil uses two configuration files at the root of your project: docanvil.toml for project settings and nav.toml for navigation structure.
docanvil.toml
[project]
name = "My Docs"
[project]
name = "My Docs"
content_dir = "docs"
[build]
output_dir = "dist"
base_url = "/my-project/"
[theme]
custom_css = "theme/custom.css"
color_mode = "both"
[theme.variables]
color-primary = "#059669"
font-body = "Georgia, serif"
[search]
enabled = true
[charts]
enabled = true
mermaid_version = "11"
[locale]
default = "en"
enabled = ["en", "fr"]
auto_detect = true
[locale.display_names]
en = "English"
fr = "Français"
[locale.flags]
en = "🇺🇸"
[version]
current = "v2"
enabled = ["v1", "v2"]
[version.display_names]
v1 = "v1.0"
v2 = "v2.0 (latest)"
[pdf]
cover_page = true
author = "Your Name"
paper_size = "A4"
[doctor]
max_paragraph_words = 150
heading_adjacent_separator = true
Required field
The name field under [project] is required. DocAnvil will fail to load without it.
[project] Section
| Key | Default | Description |
|---|---|---|
name |
(required) | Project name displayed in the sidebar and page titles |
content_dir |
"docs" |
Directory containing your Markdown files |
[build] Section
| Key | Default | Description |
|---|---|---|
output_dir |
"dist" |
Directory where the static site is generated |
base_url |
"/" |
URL path prefix for subfolder deployments (e.g. "/my-project/") |
site_url |
None |
Full site URL (e.g. "https://example.com/") for canonical URLs, hreflang tags, and sitemap |
Recommended for i18n
Setting site_url is strongly recommended when using localisation. It enables absolute hreflang URLs, canonical <link> tags, and og:url meta tags — all important for multilingual SEO.
[theme] Section
| Key | Default | Description |
|---|---|---|
name |
None |
Reserved for future theme selection |
custom_css |
None |
Path to a custom CSS file loaded after the default theme |
color_mode |
"light" |
Color mode: "light", "dark", or "both" (light + dark with toggle) |
variables |
{} |
CSS variable overrides injected as :root properties |
Variables are specified as key-value pairs where the key is the CSS variable name (without --) and the value is any valid CSS value:
[theme.variables]
color-primary = "#059669"
color-bg = "#fafafa"
font-body = "Inter, sans-serif"
content-max-width = "960px"
See CSS Variables for the complete list of available variables.
[search] Section
| Key | Default | Description |
|---|---|---|
enabled |
true |
Enable or disable full-text search |
When enabled, DocAnvil generates a search-index.json file at build time and adds a search input to the header. Search is powered by MiniSearch.js, loaded from a CDN on first use. Set enabled = false to remove the search UI and skip index generation.
[charts] Section
| Key | Default | Description |
|---|---|---|
enabled |
true |
Enable or disable Mermaid diagram rendering |
mermaid_version |
"11" |
Major version of Mermaid.js to load from CDN |
When enabled, pages containing :::mermaid blocks will load Mermaid.js and render diagrams client-side. When disabled, :::mermaid content renders as preformatted text.
[locale] Section
| Key | Default | Description |
|---|---|---|
default |
None |
Default locale code (e.g. "en"). Required to enable i18n. |
enabled |
[] |
List of enabled locale codes (e.g. ["en", "fr", "de"]) |
auto_detect |
true |
Auto-detect the user's browser language and redirect on first visit |
display_names |
{} |
Human-readable names for locales shown in the language switcher |
flags |
{} |
Flag emoji overrides for locales (e.g. {"en": "🇺🇸"} to use US flag instead of default 🇬🇧) |
When both default and enabled are set, DocAnvil switches to multi-language mode: each locale gets its own URL prefix (/en/, /fr/), its own navigation and search index, and a language switcher appears in the header.
[locale]
default = "en"
enabled = ["en", "fr", "de"]
auto_detect = true
[locale.display_names]
en = "English"
fr = "Français"
de = "Deutsch"
[locale.flags]
en = "🇺🇸" # Use US flag instead of default GB
Need details?
See Localisation for a complete walkthrough of setting up multi-language docs, including file naming, per-locale navigation, and translation coverage.
[version] Section
| Key | Default | Description |
|---|---|---|
current |
(last in enabled) |
The current/latest version code — used for the root redirect and the older-version banner. Defaults to the last entry in enabled when not set. |
enabled |
[] |
List of version directory names to build (e.g. ["v1", "v2"]). Each must have a matching subdirectory in your content directory. |
display_names |
{} |
Human-readable names shown in the version switcher (e.g. {"v2": "v2.0 (latest)"}) |
When enabled is non-empty, DocAnvil switches to multi-version mode: each version gets its own URL prefix (/v1/, /v2/), its own navigation and search index, and a version switcher appears in the header. Pages in older versions automatically show a banner linking to the latest version.
[version]
current = "v2"
enabled = ["v1", "v2"]
[version.display_names]
v1 = "v1.0"
v2 = "v2.0 (latest)"
Need details?
See Versioning for a complete walkthrough of setting up multi-version docs, including directory layout, per-version navigation, the version switcher, and composing versioning with i18n.
[pdf] Section
| Key | Default | Description |
|---|---|---|
author |
None |
Author name shown on the cover page and in the running page header |
cover_page |
false |
Prepend a cover page with the project title and author before the table of contents |
paper_size |
"A4" |
Paper size: "A3", "A4", "A5", "Letter", "Legal", "Tabloid" (case-insensitive) |
custom_css |
None |
Path (relative to project root) to a CSS file injected into the PDF output |
Need details?
See PDF Export for the full guide: cover pages, paper sizes, RTL support, per-locale export, and custom CSS.
[doctor] Section
| Key | Default | Description |
|---|---|---|
max_paragraph_words |
150 |
Word count threshold for the long-paragraph readability check. Use 0 to disable the check entirely. |
heading_adjacent_separator |
true |
Warn when a heading is directly adjacent to a horizontal rule. Set false to opt out. |
The [doctor] section configures the docanvil doctor readability linter. The default settings are intentionally permissive — tighten the threshold for higher-quality writing standards.
[doctor]
max_paragraph_words = 100 # Flag paragraphs over 100 words
heading_adjacent_separator = false # Disable the separator-next-to-heading check
Need details?
See CLI Commands → Readability checks for the full list of checks, their severities, and what each one catches.
nav.toml
The navigation file controls the sidebar structure. It uses TOML's array-of-tables syntax and supports pages, separators, and groups.
Page Entries
The simplest entry links to a page by its slug (the file path relative to content_dir, without the .md extension):
[[nav]]
page = "index"
[[nav]]
page = "guides/getting-started"
Label Overrides
By default, the sidebar label is derived from the slug (getting-started becomes "Getting Started"). Override it with label:
[[nav]]
page = "guides/getting-started"
label = "Installation"
Separators
Add visual dividers between sections. A labeled separator shows text:
[[nav]]
separator = "Guides"
An unlabeled separator draws a horizontal line:
[[nav]]
separator = true
Groups
Groups create collapsible sections in the sidebar. Each group has a label and an array of children in group:
[[nav]]
label = "Reference"
group = [
{ page = "reference/cli", label = "CLI Commands" },
{ page = "reference/project-structure" },
{ page = "reference/css-variables", label = "CSS Variables" },
]
Linked Group Headers
Add a page field to make the group header itself a clickable link:
[[nav]]
label = "Writing Content"
page = "writing/markdown"
group = [
{ page = "writing/wiki-links", label = "Links & Popovers" },
{ page = "writing/components" },
]
Clicking "Writing Content" navigates to the Markdown page, while the arrow expands the group.
Child Separators
You can add separators inside groups to organize children:
[[nav]]
label = "Reference"
group = [
{ page = "reference/cli", label = "CLI Commands" },
{ separator = "Project" },
{ page = "reference/project-structure" },
{ page = "reference/css-variables", label = "CSS Variables" },
]
Autodiscover
You can use the autodiscover option to selectively autodiscover a folder and add it to the navigation:
[[nav]]
autodiscover = "api"
You can also use autodiscover with a collapsible group:
[[nav]]
label = "Reference"
autodiscover = "reference"
Auto-Discovery Fallback
If nav.toml is absent, DocAnvil auto-discovers all .md files in the content directory and builds the navigation from the directory structure. Files are sorted alphabetically, and directory names become group labels.
Related Pages
- Theming — CSS variables, custom CSS, and template overrides
- PDF Export — full PDF export guide
- Versioning — multi-version docs setup and version switcher
- Project Structure — how files map to pages and slugs
Note
The header includes a filter input that searches page labels in real time. This works with any navigation structure.