6ebb5dad9 Remove file 27cc23ef4 Hugo 0.84.4 94dccbfa4 Merge branch 'tempv0.84.4' e9d8b61fb releaser: Add release notes to /docs for release of 0.84.4 51e472005 Improve readability of examples on shortcode templates page 0aef26479 Fix lookup order typos (#1484) 534a527fe Fix two typos (#1483) 394aabd5a Higo "0.84.3 03ee92c1c Merge branch 'tempv0.84.3' 96a8be0f1 releaser: Add release notes to /docs for release of 0.84.3 9a770323f Update index.md 7f65cfcbe Hugo 0.84.2 444422515 releaser: Add release notes to /docs for release of 0.84.2 a2f29c5d8 modules: Add module.import.noMounts config e00e4a7e7 releaser: Add release notes to /docs for release of 0.84.2 af04b53b3 modules: Add module.import.noMounts config f7d5669c7 Remove Appernetic (#1481) 14f8d4029 Clarify interaction of sections and top-level leaf bundles d140b6a62 Update lookup-order.md 399904959 Update shortcode-templates.md e78aa4865 Hugo 0.84.1 35d7c1c22 Merge branch 'tempv0.84.1' a6be65b0d releaser: Add release notes to /docs for release of 0.84.1 7b3b3ca45 Hugo 0.84.0 News Grammar fixes cbc23bf5a Remove trailing newlines 69349198d Fix erroridf docs dbc1157c1 Fix missing deep git-subtree-dir: docs git-subtree-split: 6ebb5dad9a87655196c0990d88d50a2248df5c54
3.9 KiB
title | linktitle | description | date | publishdate | lastmod | categories | keywords | menu | weight | draft | aliases | toc | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Content Sections | Sections | Hugo generates a **section tree** that matches your content. | 2017-02-01 | 2017-02-01 | 2017-02-01 |
|
|
|
50 | false |
|
true |
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) 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).
{{% 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.
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. _index.md
).
{{% 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" .) }}
Section Page Variables and Methods
Also see Page Variables.
{{< readfile file="/content/en/readfiles/sectionvars.md" 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/post-1.md
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/posts.md
.