Context Variables

Different templates receive different context variables.

Page templates (page.html)

VariableTypeDescription
page.titlestringFrom frontmatter
page.contentstringRendered HTML (use with | safe)
page.permalinkstringFull URL path
page.pathstringURL route (e.g. /blog/my-post/)
page.weightintegerSort weight
page.tocstringTable of contents HTML
page.ancestorsarrayParent section paths
page.last_updatedstringFile modification time
page.descriptionstringFrom extra.description (if set)
page.extraobjectCustom frontmatter fields

Section templates (section.html, index.html)

VariableTypeDescription
section.titlestringFrom frontmatter
section.contentstringRendered HTML (use with | safe)
section.permalinkstringFull URL path
section.pathstringURL route
section.weightintegerSort weight
section.last_updatedstringFile modification time
section.ancestorsarrayParent section paths
section.pagesarrayPages in this section (sorted by weight)
section.subsectionsarrayChild sections (sorted by weight)
section.tocstringTable of contents HTML
section.extraobjectCustom frontmatter fields

Each item in section.pages has: title, permalink, path, weight, toc, description, extra.

Each item in section.subsections has: title, permalink, path, weight, extra, pages.

Global variables

Available in all templates:

VariableTypeDescription
config.titlestringFrom root _index.md frontmatter title
config.descriptionstringFrom root _index.md frontmatter description
root.subsectionsarrayTop-level sections (for navigation)

A sidebar that lists all sections and their pages:

html
{% for sub in root.subsections %}
<div class="nav-section">
    <h3><a href="{{ sub.permalink }}">{{ sub.title }}</a></h3>
    <ul>
        {% for page in sub.pages %}
        <li><a href="{{ page.permalink }}">{{ page.title }}</a></li>
        {% endfor %}
    </ul>
</div>
{% endfor %}