Templates

Source   Edit  

Templates

Body Templates

ndgBook supports three body layout templates:

  1. `doc.body_toc_sidebar`: The default for standalone Markdown docs. Renders a sidebar with navigation, search box, and table of contents
  2. `doc.body_toc_group`: Used for API documentation with grouping controls. Includes type/proc grouping dropdowns
  3. `doc.body_toc`: Simple layout with TOC at the top and content below

The sidebar template (doc.body_toc_sidebar) includes these substitution variables:

VariableDescription
$navNavigation HTML from SUMMARY.md
$tableofcontentsPage-level heading TOC
$contentRendered page body
$moduledescModule description
$seeSrcSource link
$deprecationMsgDeprecation 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.