diff --git a/content/about-hugo/_index.md b/content/about-hugo/_index.md index b35a5319b..b0b44fd1c 100644 --- a/content/about-hugo/_index.md +++ b/content/about-hugo/_index.md @@ -2,9 +2,9 @@ title: Introduction to Hugo linktitle: Introduction to Hugo description: Hugo's features, roadmap, and license, as well as the motivation behind creating Hugo. -date: 2016-02-01 -publishdate: 2016-02-01 -lastmod: 2016-02-01 +date: 2017-02-01 +publishdate: 2017-02-01 +lastmod: 2017-02-01 layout: single weight: 01 draft: false diff --git a/content/content-management/_index.md b/content/content-management/_index.md index 4860f701a..330168dba 100644 --- a/content/content-management/_index.md +++ b/content/content-management/_index.md @@ -1,7 +1,7 @@ --- -title: "Content Management: Overview" -linktitle: "Content Management: Overview" -description: Content organization, summaries, archetypes, front matter, and supported formats. +title: "Content Management: Introduction" +linktitle: "Content Management: Introduction" +description: An introduction to how Hugo expects you to organize your content. date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 diff --git a/content/content-management/archetypes.md b/content/content-management/archetypes.md index 5809b1c4b..235a78715 100644 --- a/content/content-management/archetypes.md +++ b/content/content-management/archetypes.md @@ -14,7 +14,7 @@ aliases: [] notes: --- -**Archetypes** are content files in the [archetypes directory][] of your project that contain pre-configured [front matter][] for your website's [content types][]. Archetypes facilitate consistent metadata across your website content and allow content authors to quickly generate instances of a content type via the `hugo new` command. +**Archetypes** are content files in the [archetypes directory][] of your project that contain preconfigured [front matter][] for your website's [content types][]. Archetypes facilitate consistent metadata across your website content and allow content authors to quickly generate instances of a content type via the `hugo new` command. Hugo's generator assumes your working directory is the content folder at the root of your project. Hugo is able to infer the appropriate archetype by assuming the content type from the content section passed to the CLI command: diff --git a/content/content-management/content-sections.md b/content/content-management/content-sections.md index 894a5c14d..0c979b4d5 100644 --- a/content/content-management/content-sections.md +++ b/content/content-management/content-sections.md @@ -19,26 +19,27 @@ Hugo believes that you organize your content with a purpose. The same structure Following this pattern, Hugo uses the top level of your content organization as the **content section**. -The [example site][] used throughout the Hugo docs includes three sections: "authors," "events," and "posts": +The [example site][] used throughout the Hugo docs includes three sections: "authors," "events," and "posts". The following illustrates both the source organization and the default URL structure for the rendered files: ```bash -./content - |—–authors - |––_index.md - |––jon-doe.md - |––jane-doe.md - |––events - |––_index.md - |––event-1.md - |––event-2.md - |––event-3.md - |––posts - |--_index.md - |––post-1.md - |––post-2.md - |––post-3.md - |––post-4.md - |––post-5.md +. +└── 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 @@ -48,14 +49,15 @@ Hugo will automatically create pages for each section root that list all of the 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` in a content section as a workaround to emulate the behavior of `_index.md`. The workaround works...*sometimes*. The order of page rendering can be unpredictable in Hugo. What works now may fail to render appropriately once you begin adding more content to your site. It is *strongly advised* to use the *preferred* content section organization and `_index.md`. +Hugo themes developed before v0.18 often used an `index.md` in a content section as a hack to emulate the behavior of `_index.md`. The hack may work...*sometimes*. The order of page rendering can be unpredictable in Hugo. What works now may fail to render appropriately once you begin adding more content to your site. It is *strongly advised* to use `_index.md` the *preferred* content section index page. **Note:** `_index.md`'s layout is a [list template](/templates/list-and-section-templates/). {{% /warning %}} -## Content Section and Content Types +## Content Section vs Content Types -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 and if using an [archetype][] will generate front matter according to `archetypes/posts.md`. +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 and if using an [archetype][] will generate front matter according to `archetypes/posts.md`. [archetype]: /content-management/archetypes/ +[content type]: /content-management/content-types/ [example site]: /getting-started/ [directory structure]: /project-organization/directory-structure/ diff --git a/content/content-management/content-types.md b/content/content-management/content-types.md index dc4639837..4d7eca723 100644 --- a/content/content-management/content-types.md +++ b/content/content-management/content-types.md @@ -14,13 +14,58 @@ aliases: [/content/types] notes: --- -Hugo provides full support for content types. A content type can have a unique set of metadata (i.e., [front matter][]) or customized [template][] and can be created by the `hugo new` command via content [archetypes][]. +Hugo provides full support for sites with multiple content types. A **content type** can have a unique set of metadata (i.e., [front matter][]) or customized [template][] and can be created by the `hugo new` command via content [archetypes][]. + +A good example of when multiple types are needed is to look at [Tumblr][]. A piece of "content" could be a photo, quote or post, each with different meta data and rendered differently. + +## Assigning a content type + +Hugo assumes that your site will be organized into [sections](/content/sections/) +and each section will use the corresponding type. If you are taking advantage of +this, then each new piece of content you place into a section will automatically +inherit the type. + +Alternatively, you can set the type in the meta data under the key "`type`". +## Creating New Content of a Specific Type + +You can manually add files to your content directories, but Hugo has the ability to create and populate a new content file with preconfigured front matter via [archetypes][]. +## Defining a content type +Creating a new content type is easy in Hugo. You simply provide the templates and archetype +that the new type will use. You only need to define the templates, archetypes and/or views +unique to that content type. Hugo will fall back to using the general templates and default archetype +whenever a specific file is not present. + +*Remember, all of the following are optional:* + +### Create Type Directory + +Create a directory with the name of the type in `/layouts`. Type is always singular. *E.g. `/layouts/post`*. + +### Create single template + +Create a file called `single.html` inside your directory. *E.g. `/layouts/post/single.html`*. + +### Create list template + +Create a file called `post.html` inside the section lists template directory, `/layouts/section`. *E.g. `/layouts/section/post.html`*. + +### Create views + +Many sites support rendering content in a few different ways, for instance, a single page view and a summary view to be used when displaying a [list of contents on a single page][]. Hugo makes no assumptions about how you want to display your content and will support as many different views of a content type as your site requires. All that is required for these additional views is that a template exists in each `/layouts/TYPE` directory with the same name. + +### Create a corresponding archetype + +Create a file called type.md in the `/archetypes` directory. *E.g. `/archetypes/post.md`*. + +More details about archetypes can be found at the [archetypes docs](/content/archetypes/). [archetypes]: /content-management/archetypes/ [front matter]: /content-management/front-matter/ -[template]: /templates/ \ No newline at end of file +[list of contents on a single page]: /templates/list-and-section-templates/ +[template]: /templates/ +[Tumblr]: https://www.tumblr.com/ \ No newline at end of file diff --git a/content/templates/list-and-section-page-templates.md b/content/templates/list-and-section-templates.md similarity index 72% rename from content/templates/list-and-section-page-templates.md rename to content/templates/list-and-section-templates.md index 189bedc67..fedbd9720 100644 --- a/content/templates/list-and-section-page-templates.md +++ b/content/templates/list-and-section-templates.md @@ -1,6 +1,6 @@ --- -title: List and Section Page Templates -linktitle: List and Section Page Templates +title: List and Section Templates +linktitle: List and Section Templates description: date: 2017-02-01 publishdate: 2017-02-01 diff --git a/content/templates/template-views.md b/content/templates/view-templates.md similarity index 86% rename from content/templates/template-views.md rename to content/templates/view-templates.md index 3e0021e5f..61c17c21e 100644 --- a/content/templates/template-views.md +++ b/content/templates/view-templates.md @@ -1,5 +1,5 @@ --- -title: Template Views +title: View Templates linktitle: description: date: 2017-02-01 diff --git a/themes/hugodocs/layouts/_default/section.html b/themes/hugodocs/layouts/_default/section.html index cfb976fb5..39df2cf1e 100644 --- a/themes/hugodocs/layouts/_default/section.html +++ b/themes/hugodocs/layouts/_default/section.html @@ -9,6 +9,7 @@
{{.Content}} + {{partial "contents-list.html" .}}
{{partial "content-footer.html" . }} {{partial "table-of-contents.html" . }} diff --git a/themes/hugodocs/layouts/_default/taxonomy.html b/themes/hugodocs/layouts/_default/taxonomy.html index ebb241ef8..638ce225c 100644 --- a/themes/hugodocs/layouts/_default/taxonomy.html +++ b/themes/hugodocs/layouts/_default/taxonomy.html @@ -4,18 +4,7 @@

{{.Data.Plural}}: {{ .Title }}

- {{range .Data.Pages}} -
-
-

{{.Title}}

-
- - -
-
-

{{.Description}}

-
- {{end}} + {{partial "contents-list.html" . }}
{{ end }} \ No newline at end of file diff --git a/themes/hugodocs/layouts/partials/content-footer.html b/themes/hugodocs/layouts/partials/content-footer.html index 8e1c3f896..dd15c4014 100644 --- a/themes/hugodocs/layouts/partials/content-footer.html +++ b/themes/hugodocs/layouts/partials/content-footer.html @@ -1,13 +1,14 @@