Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
title linktitle description date publishdate lastmod categories keywords menu weight draft aliases toc
Content Sections
Hugo generates a **section tree** that matches your content.
content management
content types
parent weight

A Section is a collection of pages that gets defined based on the organization structure under the content/ directory.

By default, all the first-level directories under content/ form their own sections (root sections).

If a user needs to define a section foo at a deeper level, they need to create a directory named foo with an file (see Branch Bundles for more information).

{{% note %}} A section cannot be defined or overridden by a front matter parameter -- it is strictly derived from the content organization structure. {{% /note %}}

Nested Sections

The sections can be nested as deeply as you need.

└── blog        <-- Section, because first-level dir under content/
    ├── funny-cats
    │   ├──
    │   └── kittens         <-- Section, because contains
    │       └──
    └── tech                <-- Section, because contains

The important part to understand is, that to make the section tree fully navigational, at least the lower-most section needs a content file. (e.g.

{{% note %}} When we talk about a section in correlation with template selection, it is currently always the root section only (/blog/funny-cats/mypost/ => blog).

If you need a specific template for a sub-section, you need to adjust either the type or layout in front matter. {{% /note %}}

Example: Breadcrumb Navigation

With the available section variables and methods you can build powerful navigation. One common example would be a partial to show Breadcrumb navigation:

{{< code file="layouts/partials/breadcrumb.html" download="breadcrumb.html" >}}

    {{ template "breadcrumbnav" (dict "p1" . "p2" .) }}
{{ define "breadcrumbnav" }} {{ if .p1.Parent }} {{ template "breadcrumbnav" (dict "p1" .p1.Parent "p2" .p2 ) }} {{ else if not .p1.IsHome }} {{ template "breadcrumbnav" (dict "p1" .p1.Site.Home "p2" .p2 ) }} {{ end }} {{ .p1.Title }} {{ end }} {{< /code >}}

Section Page Variables and Methods

Also see Page Variables.

{{< readfile file="/content/en/readfiles/" markdown="true" >}}

Content Section Lists

Hugo will automatically create pages for each root section that list all of the content in that section. See the documentation on section templates for details on customizing the way these pages are rendered.

Content Section vs Content Type

By default, everything created within a section will use the content type that matches the root section name. For example, Hugo will assume that posts/ has a posts content type. If you are using an archetype for your posts section, Hugo will generate front matter according to what it finds in archetypes/