Sections

Group pages into sections and nested sections, and navigate the section tree in templates.

A section is a group of pages under one directory: every directory directly below content/, and a deeper directory that has an _index.md.

text
content/
├── docs/                 section /docs/
│   ├── _index.md
│   ├── install.md
│   └── guides/           section /docs/guides/ (it has an _index.md)
│       ├── _index.md
│       └── deploy.md
└── blog/                 section /blog/ (top level: no _index.md needed)
    └── hello.md

A section’s page uses section.html (or list.html) and lists its pages. _index.md gives it a title, content and front matter; without one the title is the directory name, title-cased.

In templates#

page.sectionThe top-level section key: docs for /docs/guides/deploy/.
page.parentThe section the page is in (none for the home page).
page.current_sectionThe page itself if it is a section, else its parent.
page.first_sectionThe top-level section the page is in.
page.ancestorsEvery section above the page, nearest first.
page.pagesOn a section: its pages and subsections.
page.regular_pagesOn a section: its regular pages.
page.regular_pages_recursiveOn a section: every regular page below it.
page.sectionsOn a section: its subsections.
site.sectionsThe top-level sections.

Lists of pages hold summary values, without the relations above: use p | deref to get a listed page’s own pages. A breadcrumb trail:

html
<nav aria-label="Breadcrumbs">
  {% for a in page.ancestors | reverse %}
    <a href="{{ a.rel_permalink }}">{{ a.link_title }}</a> ›
  {% endfor %}
  {{ page.title }}
</nav>

Order#

Lists are in the default order: by weight (pages without a weight last), then newest date first, then link title. Sort otherwise with filters: page.pages | by_title, by_date | reverse, sort_by(attribute="params.order").

Main sections#

site.main_sections lists the sections of the main content — the mainSections configuration, else the section with the most pages — for themes that show “recent posts” without knowing the section’s name.

    Type to search titles, headings and text.