Examples
EN

Sections

Sections are directories that group related content. They require an _index.md file.

Creating a Section

content/
└── blog/
    ├── _index.md     # Section index → /blog/
    ├── first.md      # Page → /blog/first/
    └── second.md     # Page → /blog/second/

Section Index

Every section needs an _index.md:

+++
title = "Blog"
description = "Latest articles"
sort_by = "date"
+++

Welcome to my blog.

Front Matter

Field Type Default Description
title string — Section title (required)
description string — Section description
template string "section" Template to use
page_template string — Default template for pages
sort_by string "date" Sort by: date, published, weight, title (see Sort direction)
reverse bool false Flip the natural sort order (see Sort direction)
paginate int — Items per page (paginate_by is accepted as an alias); 0 disables pagination for the section
pagination_enabled bool — Turn pagination on or off for this section, overriding paginate and the site-wide [pagination] setting
paginate_path string "page" Path segment for pager URLs (default produces /blog/page/2/)
transparent bool false Pass pages to parent
generate_feeds bool false Generate RSS feed
redirect_to string — Write an HTML redirect page to this URL (or an @/ content path such as @/blog/post.md) instead of rendering the section
draft bool false Exclude from production
weight int 0 Section sort order
cascade table — Defaults inherited by descendants (see Cascade)

Cascade

A section's [cascade] table sets front matter defaults for every page and section below it. A page's own front matter always wins, and deeper cascades override shallower ones. The section declaring the cascade is not affected.

+++
title = "Blog"

[cascade]
template = "post"
tags = ["blog"]

[cascade.extra]
banner = "default-banner.png"
+++

Every page under the section now renders with the post template, carries the blog tag, and exposes page.extra.banner, unless it sets those fields itself. extra and taxonomies merge per key: the page's own keys win, cascaded keys fill the gaps.

Cascadable keys: template, draft, render, toc, insert_anchor_links, in_sitemap, in_search_index, tags, taxonomies, authors, extra. URL-affecting keys (slug, path, aliases) cannot cascade and are ignored with a warning.

On multilingual sites, a cascade only applies within its own language tree: _index.ko.md cascades to .ko pages, _index.md to default-language pages.

Sort direction

Each sort_by value has a different natural direction, chosen to match what authors usually want:

sort_by Default order With reverse = true
date Newest first (descending) Oldest first
published Newest first (descending) Oldest first
weight Lowest weight first (ascending) Highest weight first
title A → Z (ascending) Z → A

A page's date order uses its updated date when it has one, so a revised post moves up the list; published orders by date alone and ignores updated, which keeps a chronological archive stable when an old post is revised; pages without any date sort last (first with reverse = true, which flips the whole list), after pages dated before 1970 too. title compares titles byte by byte, so uppercase letters sort before lowercase ones and accented letters come after z.

reverse flips whichever direction is natural for the chosen sort_by. For example, a blog index sorted by date is newest-first by default; setting reverse = true switches it to oldest-first.

+++
title = "Blog"
sort_by = "date"
# reverse = false (default) → newest first
# reverse = true            → oldest first
+++

Examples

Blog with Pagination

+++
title = "Blog"
sort_by = "date"
paginate = 10
paginate_path = "p"
+++

Generates: /blog/, /blog/p/2/, /blog/p/3/

With the default paginate_path = "page", the URLs are /blog/page/2/, /blog/page/3/, and so on, while page 1 always stays at the section URL.

Documentation

+++
title = "Docs"
page_template = "doc-page"
sort_by = "weight"
+++

All pages use doc-page.html template and sort by weight.

Section with Feed

+++
title = "News"
generate_feeds = true
+++

Generates /news/rss.xml.

Full Front Matter Reference

All available fields in one block. Copy and remove what you don't need.

+++
title = "Section Title"
description = "Section description"
template = "section"
page_template = "custom-page"
sort_by = "date"
reverse = false
paginate = 10
pagination_enabled = true
paginate_path = "page"
transparent = false
generate_feeds = true
redirect_to = ""
draft = false
weight = 0
+++

Nested Sections

Sections can contain other sections:

content/
└── docs/
    ├── _index.md           # /docs/
    ├── getting-started/
    │   ├── _index.md       # /docs/getting-started/
    │   └── install.md      # /docs/getting-started/install/
    └── guides/
        ├── _index.md       # /docs/guides/
        └── deploy.md       # /docs/guides/deploy/

Access subsections in templates:

{% for sub in section.subsections %}
<a href="{{ sub.url }}">{{ sub.title }}</a>
<small>({{ sub.pages_count }})</small>
{% endfor %}

Template Variables

When rendering a section page (_index.md), these variables are available:

Variable Type Description
section.title String Current section title
section.description String Current section description
section.pages Array<Page> Pages shown in the current section list
section.pages_count Int Number of items in section.pages
section.list String Pre-rendered HTML list (same value as section_list)
section.subsections Array<Section> Direct child sections (title, description, url, pages_count), ordered by weight then path. On the root _index.md these are the top-level sections
section.assets Array<String> Colocated section assets
section.page_template String Default template name for child pages
section.paginate_path String Pagination path segment
section.redirect_to String Redirect target if configured
section_list String Same as section.list
pagination String Pre-rendered pagination HTML
paginator Object Structured pagination object — see Data Model › Paginator

Use page.url for the current section URL.

section.list / section_list

<ul class="auto-list">
  {{ section.list | safe }}
</ul>

For building a custom pagination UI with paginator, see Data Model › Paginator.

Transparent Sections

Use transparent = true to merge pages into parent section:

+++
title = "2024 Posts"
transparent = true
+++

Pages appear in the parent's section.pages list.

Asset Colocation

Just like regular pages, sections can have colocated assets. Place non-markdown files in the same directory as the _index.md file.

Example Structure:

content/
└── gallery/
    ├── _index.md       <-- The section index
    ├── banner.jpg      <-- Section asset
    └── icon.png        <-- Section asset

These assets are copied to the output directory relative to the section.

Accessing Assets in Templates

You can access the list of section assets in your templates using section.assets. This returns an array of relative paths to the files (from the content directory).

<!-- In section.html -->
<div class="gallery">
  {% for asset in section.assets %}
    <img src="{{ get_url(path=asset) }}" alt="Section Asset">
  {% endfor %}
</div>

Section vs Page

File Type URL
_index.md Section index /blog/
index.md Regular page /blog/

Use _index.md when you need to list child pages.

See Also