Templates
Body Templates
ndgBook supports three body layout templates:
- `doc.body_toc_sidebar`: The default for standalone Markdown docs. Renders a sidebar with navigation, search box, and table of contents
- `doc.body_toc_group`: Used for API documentation with grouping controls. Includes type/proc grouping dropdowns
- `doc.body_toc`: Simple layout with TOC at the top and content below
The sidebar template (doc.body_toc_sidebar) includes these substitution variables:
| Variable | Description |
|---|---|
| $nav | Navigation HTML from SUMMARY.md |
| $tableofcontents | Page-level heading TOC |
| $content | Rendered page body |
| $moduledesc | Module description |
| $seeSrc | Source link |
| $deprecationMsg | Deprecation warning |
Customizing Appearance
You can override any template by creating a nimdoc.cfg file in your project root. The config file uses standard Nim configuration syntax:
doc.nav = """
<ul class="simple">
<li><a href="/index.html">Home</a></li>
</ul>
"""
doc.body_toc_sidebar = """
<div class="row">
<div class="three columns">
$nav
$tableofcontents
</div>
<div class="nine columns" id="content">
$content
</div>
</div>
"""
Note:
Template variables are case-sensitive. Use $Content only if the template expects uppercase. Most variables use lowercase.