36d7e22f Document fmt.{print, println} template functions 79a72fce Fix link to page variables 00342ca9 Fix broken link on highlight page 15f44952 Fix link in v0.28 release notes 0100df73 Fix code examples for math.{Ceil, Floor, Round} a354a69b Fix broken netlify.toml 4995e5df Merge branch 'master' of github.com:gohugoio/hugoDocs 9cdd990a Hugo 0.29 463558f9 Document math.Log template function 588499af Add nohup.out to .gitignore db8ddcf7 Change name of post files in example to use post prefix 296ec01f Add ox-hugo Emacs package to the tools section f060d6d1 Fix math.Ceil, Floor, and Round naming a2262d24 Document strings.TrimPrefix and TrimSuffix template functions 80c1ce63 Document strings.TrimLeft and TrimRight template functions 2921088d Document urls.Parse template function f0133079 Document math.{ceil, floor, round} template functions 82863808 Fix typo in migration tools section d5215d61 Add link to syntax hl docs in release notes 541f0686 Update versions 275ce2b4 Update 0.28 release notes 886713a1 Add release notes for 0.28 bed02e5f Merge branch 'next' 8e3b1ac4 Add a note about branches 1662b9d0 Add missing Disqus links in templates/internal.md git-subtree-dir: docs git-subtree-split: 36d7e22f5c21c550bd87782d2ddca666178fe1ff
3.8 KiB
title | linktitle | description | date | publishdate | lastmod | categories | keywords | menu | weight | draft | aliases | toc | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Content Sections | Sections | Hugo supports content sections, which according to Hugo's default behavior, will reflect the structure of the rendered website. | 2017-02-01 | 2017-02-01 | 2017-02-01 |
|
|
|
50 | false |
|
true |
{{% note %}} This section is not updated with the new nested sections support in Hugo 0.24, see https://github.com/gohugoio/hugoDocs/issues/36 {{% /note %}} {{% todo %}} See above {{% /todo %}}
Hugo believes that you organize your content with a purpose. The same structure that works to organize your source content is used to organize the rendered site (see directory structure).
Following this pattern, Hugo uses the top level of your content organization as the content section.
The following example shows a content directory structure for a website that has three sections: "authors," "events," and "posts":
.
└── content
├── authors
| ├── _index.md // <- example.com/authors/
| ├── john-doe.md // <- example.com/authors/john-doe/
| └── jane-doe.md // <- example.com/authors/jane-doe/
└── events
| ├── _index.md // <- example.com/events/
| ├── event-1.md // <- example.com/events/event-1/
| ├── event-2.md // <- example.com/events/event-2/
| └── event-3.md // <- example.com/events/event-3/
└── posts
| ├── _index.md // <- example.com/posts/
| ├── post-1.md // <- example.com/posts/post-1/
| ├── post-2.md // <- example.com/posts/post-2/
| ├── post-3.md // <- example.com/posts/post-3/
| ├── post-4.md // <- example.com/posts/post-4/
| └── post-5.md // <- example.com/posts/post-5/
Content Section Lists
Hugo will automatically create pages for each section root 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.
As of Hugo v0.18, section pages can also have a content file and front matter. These section content files must be placed in their corresponding section folder and named _index.md
in order for Hugo to correctly render the front matter and content.
{{% warning "index.md
vs _index.md
" %}}
Hugo themes developed before v0.18 often used an index.md
(i.e., without the leading underscore [_
]) in a content section as a hack to emulate the behavior of _index.md
. The hack may work...sometimes; however, the order of page rendering can be unpredictable in Hugo. What works now may fail to render appropriately as your site grows. It is strongly advised to use _index.md
as content for your section index pages. Note: _index.md
's layout, as representative of a section, is a list page template and not a single page template. If you want to alter the new default behavior for _index.md
, configure disableKinds
accordingly in your site's configuration.
{{% /warning %}}
Content Section vs Content Type
By default, everything created within a section will use the content type that matches the 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
.