A Section is a collection of pages that gets defined based on the
organization structure under the
By default, all the first-level directories under
content/ form their own
sections (root sections) provided they constitute Branch Bundles.
Directories which are just Leaf Bundles do not form
their own sections, despite being first-level directories.
If a user needs to define a section
foo at a deeper level, they need to create
a directory named
foo with an
_index.md file (see Branch Bundles
for more information).
The sections can be nested as deeply as you need.
content └── blog <-- Section, because first-level dir under content/ ├── funny-cats │ ├── mypost.md │ └── kittens <-- Section, because contains _index.md │ └── _index.md └── tech <-- Section, because contains _index.md └── _index.md
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.
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:
Section Page Variables and Methods
Also see Page Variables.
- The page’s current section. The value can be the page itself if it is a section or the homepage.
- The page’s first section below root, e.g.
- .InSection $anotherPage
- Whether the given page is in the current section.
- .IsAncestor $anotherPage
- Whether the current page is an ancestor of the given page.
- .IsDescendant $anotherPage
- Whether the current page is a descendant of the given page.
- A section’s parent section or a page’s section.
- The section this content belongs to. Note: For nested sections, this is the first path element in the directory, for example,
/blog/funny/mypost/ => blog.
- The sections below this content.
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/post-1.md has a
type. If you are using an archetype for your
posts section, Hugo will generate front matter according to what it finds in