mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Merge commit '00c4484c7092181729f6f470805bc7d72e8ad17b'
This commit is contained in:
@@ -1,20 +1,17 @@
|
||||
---
|
||||
title: Front Matter
|
||||
linktitle:
|
||||
linkTitle: Front Matter
|
||||
description: Hugo allows you to add front matter in yaml, toml, or json to your content files.
|
||||
date: 2017-01-09
|
||||
publishdate: 2017-01-09
|
||||
lastmod: 2017-02-24
|
||||
categories: [content management]
|
||||
keywords: ["front matter", "yaml", "toml", "json", "metadata", "archetypes"]
|
||||
menu:
|
||||
docs:
|
||||
parent: "content-management"
|
||||
weight: 30
|
||||
weight: 30 #rem
|
||||
draft: false
|
||||
aliases: [/content/front-matter/]
|
||||
parent: content-management
|
||||
weight: 60
|
||||
toc: true
|
||||
weight: 60
|
||||
aliases: [/content/front-matter/]
|
||||
---
|
||||
|
||||
**Front matter** allows you to keep metadata attached to an instance of a [content type][]---i.e., embedded inside a content file---and is one of the many features that gives Hugo its strength.
|
||||
@@ -68,7 +65,7 @@ cascade
|
||||
: a map of Front Matter keys whose values are passed down to the page's descendants unless overwritten by self or a closer ancestor's cascade. See [Front Matter Cascade](#front-matter-cascade) for details.
|
||||
|
||||
date
|
||||
: the datetime assigned to this page. This is usually fetched from the `date` field in front matter, but this behaviour is configurable.
|
||||
: the datetime assigned to this page. This is usually fetched from the `date` field in front matter, but this behavior is configurable.
|
||||
|
||||
description
|
||||
: the description for the content.
|
||||
@@ -137,7 +134,7 @@ weight
|
||||
: used for [ordering your content in lists][ordering]. Lower weight gets higher precedence. So content with lower weight will come first. If set, weights should be non-zero, as 0 is interpreted as an *unset* weight.
|
||||
|
||||
\<taxonomies\>
|
||||
: field name of the *plural* form of the index. See `tags` and `categories` in the above front matter examples. _Note that the plural form of user-defined taxonomies cannot be the same as any of the predefined front matter variables._
|
||||
: field name of the *plural* form of the index. See `tags` and `categories` in the above front matter examples. *Note that the plural form of user-defined taxonomies cannot be the same as any of the predefined front matter variables.*
|
||||
|
||||
{{% note "Hugo's Default URL Destinations" %}}
|
||||
If neither `slug` nor `url` is present and [permalinks are not configured otherwise in your site `config` file](/content-management/urls/#permalinks), Hugo will use the filename of your content to create the output URL. See [Content Organization](/content-management/organization) for an explanation of paths in Hugo and [URL Management](/content-management/urls/) for ways to customize Hugo's default behaviors.
|
||||
@@ -160,9 +157,7 @@ Any node or section can pass down to descendants a set of Front Matter values as
|
||||
|
||||
### Target Specific Pages
|
||||
|
||||
{{< new-in "0.76.0" >}}
|
||||
|
||||
Since Hugo 0.76 the `cascade` block can be a slice with a optional `_target` keyword, allowing for multiple `cascade` values targeting different page sets.
|
||||
The `cascade` block can be a slice with a optional `_target` keyword, allowing for multiple `cascade` values targeting different page sets.
|
||||
|
||||
{{< code-toggle copy="false" >}}
|
||||
title ="Blog"
|
||||
@@ -181,7 +176,7 @@ kind="section"
|
||||
Keywords available for `_target`:
|
||||
|
||||
path
|
||||
: A [Glob](https://github.com/gobwas/glob) pattern matching the content path below /content. Expects Unix-styled slashes. Note that this is the virtual path, so it starts at the mount root. The matching support double-asterisks so you can match for patterns like `/blog/*/**` to match anything from the third level and down.
|
||||
: A [Glob](https://github.com/gobwas/glob) pattern matching the content path below /content. Expects Unix-styled slashes. Note that this is the virtual path, so it starts at the mount root. The matching supports double-asterisks so you can match for patterns like `/blog/*/**` to match anything from the third level and down.
|
||||
|
||||
kind
|
||||
: A Glob pattern matching the Page's Kind(s), e.g. "{home,section}".
|
||||
@@ -192,7 +187,7 @@ lang
|
||||
environment
|
||||
: A Glob pattern matching the build environment, e.g. "{production,development}"
|
||||
|
||||
Any of the above can be omitted.
|
||||
Any of the above can be omitted.
|
||||
|
||||
### Example
|
||||
|
||||
@@ -206,11 +201,9 @@ cascade:
|
||||
|
||||
With the above example the Blog section page and its descendants will return `images/typewriter.jpg` when `.Params.banner` is invoked unless:
|
||||
|
||||
- Said descendant has its own `banner` value set
|
||||
- Said descendant has its own `banner` value set
|
||||
- Or a closer ancestor node has its own `cascade.banner` value set.
|
||||
|
||||
|
||||
|
||||
## Order Content Through Front Matter
|
||||
|
||||
You can assign content-specific `weight` in the front matter of your content. These values are especially useful for [ordering][ordering] in list views. You can use `weight` for ordering of content and the convention of [`<TAXONOMY>_weight`][taxweight] for ordering content within a taxonomy. See [Ordering and Grouping Hugo Lists][lists] to see how `weight` can be used to organize your content in list views.
|
||||
@@ -221,9 +214,9 @@ It's possible to set some options for Markdown rendering in a content's front ma
|
||||
|
||||
## Front Matter Format Specs
|
||||
|
||||
* [TOML Spec][toml]
|
||||
* [YAML Spec][yaml]
|
||||
* [JSON Spec][json]
|
||||
- [TOML Spec][toml]
|
||||
- [YAML Spec][yaml]
|
||||
- [JSON Spec][json]
|
||||
|
||||
[variables]: /variables/
|
||||
[aliases]: /content-management/urls/#aliases
|
||||
|
Reference in New Issue
Block a user