mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-30 04:23:21 -05:00
2c0d1ccdcd
73f355ce Update theme 83ff50c2 Use example.com in examples 71292134 Add alias news > release-notes 2e15f642 Update theme 8eef09d2 Add Pygments configuration 572b9e75 Clean up the code shortcode use a1b2fd3b Remove the code fence language codes 1473b1d9 Remove redundant text b92c2042 Update theme 8f439c28 Edit contributing section in README 8bcf8a19 Add contributing section to README 4c44ee1c Fix broken content file 2bdc7710 Clarify .Data.Pages sorting in lists.md 092271c2 Use infinitive mood for main titles b9b8abef Update theme to reflect change to home page content b897b71b Change copy to use sentence case fd675ee5 Enable RSS feed for sections 060a5e27 Correct movie title in taxonomies.md 6a5ca96a Update displayed site name for Hub 22f4b7a4 Add example of starting up the local server d9612cb3 Update theme a8c3988a Update theme 4198189d Update theme 12d6b016 Update theme 2b1c4197 Update theme b6d90a1e Fix News release titles cfe751db Add some build info to README git-subtree-dir: docs git-subtree-split: 73f355ce0dd88d032062ea70067431ab980cdd8d
73 lines
3.8 KiB
Markdown
73 lines
3.8 KiB
Markdown
---
|
|
title: Content Sections
|
|
linktitle: Sections
|
|
description: Hugo supports content sections, which according to Hugo's default behavior, will reflect the structure of the rendered website.
|
|
date: 2017-02-01
|
|
publishdate: 2017-02-01
|
|
lastmod: 2017-02-01
|
|
categories: [content management]
|
|
#tags: [lists,sections,content types,organization]
|
|
menu:
|
|
docs:
|
|
parent: "content-management"
|
|
weight: 50
|
|
weight: 50 #rem
|
|
draft: false
|
|
aliases: [/content/sections/]
|
|
toc: 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/
|
|
| ├── event-1.md // <- example.com/posts/event-1/
|
|
| ├── event-2.md // <- example.com/posts/event-2/
|
|
| ├── event-3.md // <- example.com/posts/event-3/
|
|
| ├── event-4.md // <- example.com/posts/event-4/
|
|
| └── event-5.md // <- example.com/posts/event-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](/templates/section-templates/) and *not* a [single page template](/templates/single-page-templates/). If you want to alter the new default behavior for `_index.md`, configure `disableKinds` accordingly in your [site's configuration](/getting-started/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`.
|
|
|
|
[archetype]: /content-management/archetypes/
|
|
[content type]: /content-management/types/
|
|
[directory structure]: /getting-started/directory-structure/
|
|
[section templates]: /templates/section-templates/
|
|
|
|
|