Sections
On this page
Sections organize pages into a hierarchy. A directory containing _index.{md,org,html} defines a section. See Parsers for supported extensions.
Directory Layout
content/ ├── _index.md # Home section → / └── posts/ ├── _index.md # Section → /posts/ ├── article1.md # → /posts/article1/ └── tutorials/ # Child section → /posts/tutorials/ ├── _index.md └── intro.md # → /posts/tutorials/intro/
Front Matter
Configure a section in its _index.md:
--- title: "Articles" sort_by: "date desc" paginate: 10 template: "custom-section.html" --- This section's description is available as section.Content.
| Field | Type | Description |
|---|---|---|
title |
string | Section title |
slug |
string | Section slug |
sort_by |
string | Page ordering, using field direction |
path |
string | Custom output path; empty disables rendering |
template |
string | Custom template |
paginate |
int | Items per page; 0 disables pagination |
paginate_path |
string | Pagination path template |
paginate_filter_by |
string | Filter applied before pagination |
render |
bool | Whether to render the section |
assets |
[]string | Attachments |
formats.{name}.path |
string | Additional format's output path |
formats.{name}.template |
string | Additional format's template |
If no title is supplied, the directory name is used. See Attachments for assets.
Configuration
sections: _default: path: "{path:slug}/" sort_by: "weight,date desc,title" paginate: 0 posts: sort_by: "date desc" paginate: 5 template: "custom.html" pages: path: ""
Section settings are looked up in:
sections.{directory-path}, such asposts/tutorials.- Parent directories, such as
posts. sections._default.
When paginate_path is unset or empty, its default depends on the section's output path. See Pagination.
Path Variables
| Variable | Meaning | Example |
|---|---|---|
{lang} |
Language code | en |
{lang:optional} |
Empty for the default language | en or empty |
{path} |
Section directory path | posts/tutorials |
{path:slug} |
Slugified path | posts-tutorials |
{slug} |
Section slug | tutorials |
{title} |
Section title | Tutorials |
{title:slug} |
Slugified title | tutorials |
Directory slices such as {path[1:]}, {path[:3]}, and {path[1:]:slug} use the same syntax as page path variables. Slicing changes output paths, not section membership.
Sorting
The default is weight,date desc,title: lower weights first, then newer dates, then titles in ascending order.
Separate multiple fields with commas:
sort_by: "date desc, title asc"
Fields include date, modified, title, weight, and custom front matter fields.
Template Lookup
Snow checks the custom template value and section.html. Home sections also look for index.html.
Filter Expressions
paginate_filter_by: "'emacs' in tags and not draft"
Expressions refer to page front matter fields.
Template Variables
| Property | Type | Description |
|---|---|---|
section.File |
File | Source file information |
section.File.Path |
string | Index file path relative to the content root |
section.File.Dir |
string | Source directory |
section.File.Name |
string | Filename |
section.File.BaseName |
string | Filename without its extension |
section.File.LanguageName |
string | Language from mount metadata or the filename suffix |
section.File.Ext |
string | File extension |
section.FrontMatter |
FrontMatter | Metadata |
section.FrontMatter.{xxx} |
any | Custom metadata |
section.Toc |
[]Heading | Table of contents |
section.Lang |
string | Language code |
section.Slug |
string | Section slug |
section.Title |
string | Title |
section.Description |
string | Description |
section.Summary |
string | Summary |
section.Content |
string | Rendered index content |
section.RawContent |
string | Original index content |
section.WordCount |
int64 | Word count |
section.ReadingTime |
int64 | Estimated reading time in minutes |
section.Path |
string | Relative URL |
section.Permalink |
string | Absolute URL |
section.Pages |
Pages | Regular pages in this section |
section.HiddenPages |
Pages | Hidden pages in this section |
section.Assets |
Assets | Section attachments |
section.Formats |
Formats | Additional output formats |
section.Parent |
Section | Parent section |
section.Children |
Sections | Child sections |
section.IsHome() |
bool | Whether this is the home section |
section.Ancestors() |
Sections | Sections from the parent upward, excluding itself |
section.AllPages() |
Pages | Regular pages in this section and all descendants |
section.AllHiddenPages() |
Pages | Hidden pages in this section and all descendants |
paginator |
Paginator | Pagination context when enabled |
Related values:
| Property | Description |
|---|---|
section.Parent.Title |
Parent title |
section.Children[n].Title |
Child title |
section.Assets[n].Path |
Attachment's relative output URL |
section.Assets[n].Permalink |
Attachment's absolute output URL |
section.Formats.Find("rss") |
Find an output format |