mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-10 09:14:55 -04:00
Use code-toggle shortcode where appropriate
This commit is contained in:
parent
f11cabf375
commit
7785fa7d9f
@ -83,7 +83,7 @@ Hugo natively supports taxonomies.
|
|||||||
|
|
||||||
Without adding a single line to your [site config][config] file, Hugo will automatically create taxonomies for `tags` and `categories`. That would be the same as manually [configuring your taxonomies](#configure-taxonomies) as below:
|
Without adding a single line to your [site config][config] file, Hugo will automatically create taxonomies for `tags` and `categories`. That would be the same as manually [configuring your taxonomies](#configure-taxonomies) as below:
|
||||||
|
|
||||||
{{< code-toggle copy=false >}}
|
{{< code-toggle file="config" copy=false >}}
|
||||||
[taxonomies]
|
[taxonomies]
|
||||||
tag = "tags"
|
tag = "tags"
|
||||||
category = "categories"
|
category = "categories"
|
||||||
@ -91,7 +91,7 @@ Without adding a single line to your [site config][config] file, Hugo will autom
|
|||||||
|
|
||||||
If you do not want Hugo to create any taxonomies, set `disableKinds` in your [site config][config] to the following:
|
If you do not want Hugo to create any taxonomies, set `disableKinds` in your [site config][config] to the following:
|
||||||
|
|
||||||
{{< code-toggle copy=false >}}
|
{{< code-toggle file="config" copy=false >}}
|
||||||
disableKinds = ["taxonomy","term"]
|
disableKinds = ["taxonomy","term"]
|
||||||
{{</ code-toggle >}}
|
{{</ code-toggle >}}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ Custom taxonomies other than the [defaults](#default-taxonomies) must be defined
|
|||||||
While adding custom taxonomies, you need to put in the default taxonomies too, _if you want to keep them_.
|
While adding custom taxonomies, you need to put in the default taxonomies too, _if you want to keep them_.
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
{{< code-toggle copy=false >}}
|
{{< code-toggle file="config" copy=false >}}
|
||||||
[taxonomies]
|
[taxonomies]
|
||||||
tag = "tags"
|
tag = "tags"
|
||||||
category = "categories"
|
category = "categories"
|
||||||
@ -125,7 +125,7 @@ While adding custom taxonomies, you need to put in the default taxonomies too, _
|
|||||||
|
|
||||||
If you want to have just the default `tags` taxonomy, and remove the `categories` taxonomy for your site, you can do so by modifying the `taxonomies` value in your [site config][config].
|
If you want to have just the default `tags` taxonomy, and remove the `categories` taxonomy for your site, you can do so by modifying the `taxonomies` value in your [site config][config].
|
||||||
|
|
||||||
{{< code-toggle copy=false >}}
|
{{< code-toggle file="config" copy=false >}}
|
||||||
[taxonomies]
|
[taxonomies]
|
||||||
tag = "tags"
|
tag = "tags"
|
||||||
{{</ code-toggle >}}
|
{{</ code-toggle >}}
|
||||||
@ -156,7 +156,7 @@ If you would like the ability to quickly generate content files with preconfigur
|
|||||||
|
|
||||||
### Example: Front Matter with Taxonomies
|
### Example: Front Matter with Taxonomies
|
||||||
|
|
||||||
{{< code-toggle copy=false >}}
|
{{< code-toggle file="content/example.md" fm=true copy=false >}}
|
||||||
title = "Hugo: A fast and flexible static site generator"
|
title = "Hugo: A fast and flexible static site generator"
|
||||||
tags = [ "Development", "Go", "fast", "Blogging" ]
|
tags = [ "Development", "Go", "fast", "Blogging" ]
|
||||||
categories = [ "Development" ]
|
categories = [ "Development" ]
|
||||||
@ -191,13 +191,10 @@ Currently taxonomies only support the [default `weight => date` ordering of list
|
|||||||
|
|
||||||
If you need to add custom metadata to your taxonomy terms, you will need to create a page for that term at `/content/<TAXONOMY>/<TERM>/_index.md` and add your metadata in its front matter. Continuing with our 'Actors' example, let's say you want to add a Wikipedia page link to each actor. Your terms pages would be something like this:
|
If you need to add custom metadata to your taxonomy terms, you will need to create a page for that term at `/content/<TAXONOMY>/<TERM>/_index.md` and add your metadata in its front matter. Continuing with our 'Actors' example, let's say you want to add a Wikipedia page link to each actor. Your terms pages would be something like this:
|
||||||
|
|
||||||
{{< code file="/content/actors/bruce-willis/_index.md" >}}
|
{{< code-toggle file="content/actors/bruce-willis/_index.md" fm=true copy=false >}}
|
||||||
---
|
|
||||||
title: "Bruce Willis"
|
title: "Bruce Willis"
|
||||||
wikipedia: "https://en.wikipedia.org/wiki/Bruce_Willis"
|
wikipedia: "https://en.wikipedia.org/wiki/Bruce_Willis"
|
||||||
---
|
{{< /code-toggle >}}
|
||||||
{{< /code >}}
|
|
||||||
|
|
||||||
|
|
||||||
[`urlize` template function]: /functions/urlize/
|
[`urlize` template function]: /functions/urlize/
|
||||||
[content section]: /content-management/sections/
|
[content section]: /content-management/sections/
|
||||||
|
@ -30,11 +30,10 @@ POTENTIAL NEW CONTENT: see apply/sequence discussion: https://discourse.gohugo.i
|
|||||||
|
|
||||||
Here is an example of a content file with `names:` as a front matter field:
|
Here is an example of a content file with `names:` as a front matter field:
|
||||||
|
|
||||||
```
|
{{< code-toggle file="content/example.md" fm=true copy=false >}}
|
||||||
+++
|
title: Example
|
||||||
names: [ "Derek Perkins", "Joe Bergevin", "Tanner Linsley" ]
|
names: [ "Derek Perkins", "Joe Bergevin", "Tanner Linsley" ]
|
||||||
+++
|
{{< /code-toggle >}}
|
||||||
```
|
|
||||||
|
|
||||||
You can then use `apply` as follows:
|
You can then use `apply` as follows:
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ display_toc = true
|
|||||||
|
|
||||||
**Content**
|
**Content**
|
||||||
|
|
||||||
{{< code-toggle file="content/about.md" fm=true copy=false >}}
|
{{< code-toggle file="content/example.md" fm=true copy=false >}}
|
||||||
title = 'About'
|
title = 'Example'
|
||||||
date = 2023-01-01
|
date = 2023-01-01
|
||||||
draft = false
|
draft = false
|
||||||
display_toc = false
|
display_toc = false
|
||||||
|
@ -19,13 +19,11 @@ relatedfuncs: []
|
|||||||
|
|
||||||
The following examples pull from a content file with the following front matter:
|
The following examples pull from a content file with the following front matter:
|
||||||
|
|
||||||
{{< code file="content/blog/greatest-city.md" copy="false" >}}
|
{{< code-toggle file="content/blog/greatest-city.md" fm=true copy=false >}}
|
||||||
+++
|
|
||||||
title = "The World's Greatest City"
|
title = "The World's Greatest City"
|
||||||
location = "Chicago IL"
|
location = "Chicago IL"
|
||||||
tags = ["pizza","beer","hot dogs"]
|
tags = ["pizza","beer","hot dogs"]
|
||||||
+++
|
{{< /code-toggle >}}
|
||||||
{{< /code >}}
|
|
||||||
|
|
||||||
The following might be used as a partial within a [single page template][singletemplate]:
|
The following might be used as a partial within a [single page template][singletemplate]:
|
||||||
|
|
||||||
|
@ -33,11 +33,10 @@ SQL][wherekeyword].
|
|||||||
|
|
||||||
It can be used by dot-chaining the second argument to refer to a nested element of a value.
|
It can be used by dot-chaining the second argument to refer to a nested element of a value.
|
||||||
|
|
||||||
```
|
{{< code-toggle file="content/example.md" fm=true copy=false >}}
|
||||||
+++
|
title: Example
|
||||||
series: golang
|
series: golang
|
||||||
+++
|
{{< /code-toggle >}}
|
||||||
```
|
|
||||||
|
|
||||||
```go-html-template
|
```go-html-template
|
||||||
{{ range where .Site.Pages "Params.series" "golang" }}
|
{{ range where .Site.Pages "Params.series" "golang" }}
|
||||||
|
@ -536,16 +536,12 @@ You can provide variables to be used by templates in individual content's [front
|
|||||||
|
|
||||||
An example of this is used in the Hugo docs. Most of the pages benefit from having the table of contents provided, but sometimes the table of contents doesn't make a lot of sense. We've defined a `notoc` variable in our front matter that will prevent a table of contents from rendering when specifically set to `true`.
|
An example of this is used in the Hugo docs. Most of the pages benefit from having the table of contents provided, but sometimes the table of contents doesn't make a lot of sense. We've defined a `notoc` variable in our front matter that will prevent a table of contents from rendering when specifically set to `true`.
|
||||||
|
|
||||||
Here is the example front matter (YAML):
|
Here is the example front matter:
|
||||||
|
|
||||||
```yml
|
{{< code-toggle file="content/example.md" fm=true copy=false >}}
|
||||||
---
|
title: Example
|
||||||
title: Roadmap
|
|
||||||
lastmod: 2017-03-05
|
|
||||||
date: 2013-11-18
|
|
||||||
notoc: true
|
notoc: true
|
||||||
---
|
{{< /code-toggle >}}
|
||||||
```
|
|
||||||
|
|
||||||
Here is an example of corresponding code that could be used inside a `toc.html` [partial template][partials]:
|
Here is an example of corresponding code that could be used inside a `toc.html` [partial template][partials]:
|
||||||
|
|
||||||
|
@ -168,17 +168,15 @@ Note that in the above examples, the _output formats_ for `section`,
|
|||||||
* These names are case insensitive.
|
* These names are case insensitive.
|
||||||
* These can be overridden per `Page` in the front matter of content files.
|
* These can be overridden per `Page` in the front matter of content files.
|
||||||
|
|
||||||
The following is an example of `YAML` front matter in a content file that defines output formats for the rendered `Page`:
|
The following is an example of front matter in a content file that defines output formats for the rendered `Page`:
|
||||||
|
|
||||||
```yaml
|
{{< code-toggle file="content/example.md" fm=true copy=false >}}
|
||||||
---
|
title: Example
|
||||||
date: "2016-03-19"
|
|
||||||
outputs:
|
outputs:
|
||||||
- html
|
- html
|
||||||
- amp
|
- amp
|
||||||
- json
|
- json
|
||||||
---
|
{{< /code-toggle >}}
|
||||||
```
|
|
||||||
|
|
||||||
## List Output formats
|
## List Output formats
|
||||||
|
|
||||||
|
@ -150,16 +150,14 @@ Weights of zero are thus treated specially: if two pages have unequal weights, a
|
|||||||
|
|
||||||
Content can be assigned weight for each taxonomy that it's assigned to.
|
Content can be assigned weight for each taxonomy that it's assigned to.
|
||||||
|
|
||||||
```txt
|
|
||||||
+++
|
{{< code-toggle file="content/example.md" fm=true copy=false >}}
|
||||||
tags = [ "a", "b", "c" ]
|
tags = [ "a", "b", "c" ]
|
||||||
tags_weight = 22
|
tags_weight = 22
|
||||||
categories = ["d"]
|
categories = ["d"]
|
||||||
title = "foo"
|
title = "Example"
|
||||||
categories_weight = 44
|
categories_weight = 44
|
||||||
+++
|
{{< /code-toggle >}}
|
||||||
Front Matter with weighted tags and categories
|
|
||||||
```
|
|
||||||
|
|
||||||
The convention is `taxonomyname_weight`.
|
The convention is `taxonomyname_weight`.
|
||||||
|
|
||||||
|
@ -260,13 +260,11 @@ There are one caveat with this, and this isn't new, but it's worth mentioning he
|
|||||||
|
|
||||||
Any other value defined in the front matter in a content file, including taxonomies, will be made available as part of the `.Params` variable.
|
Any other value defined in the front matter in a content file, including taxonomies, will be made available as part of the `.Params` variable.
|
||||||
|
|
||||||
```yml
|
{{< code-toggle file="content/example.md" fm=true copy=false >}}
|
||||||
---
|
title: Example
|
||||||
title: My First Post
|
|
||||||
date: 2017-02-20T15:26:23-06:00
|
|
||||||
categories: [one]
|
categories: [one]
|
||||||
tags: [two,three,four]
|
tags: [two,three,four]
|
||||||
```
|
{{< /code-toggle >}}
|
||||||
|
|
||||||
With the above front matter, the `tags` and `categories` taxonomies are accessible via the following:
|
With the above front matter, the `tags` and `categories` taxonomies are accessible via the following:
|
||||||
|
|
||||||
@ -279,14 +277,11 @@ Page-level `.Params` are *only* accessible in lowercase.
|
|||||||
|
|
||||||
The `.Params` variable is particularly useful for the introduction of user-defined front matter fields in content files. For example, a Hugo website on book reviews could have the following front matter in `/content/review/book01.md`:
|
The `.Params` variable is particularly useful for the introduction of user-defined front matter fields in content files. For example, a Hugo website on book reviews could have the following front matter in `/content/review/book01.md`:
|
||||||
|
|
||||||
```yml
|
{{< code-toggle file="content/example.md" fm=true copy=false >}}
|
||||||
---
|
title: Example
|
||||||
...
|
|
||||||
affiliatelink: "http://www.my-book-link.here"
|
affiliatelink: "http://www.my-book-link.here"
|
||||||
recommendedby: "My Mother"
|
recommendedby: "My Mother"
|
||||||
...
|
{{< /code-toggle >}}
|
||||||
---
|
|
||||||
```
|
|
||||||
|
|
||||||
These fields would then be accessible to the `/themes/yourtheme/layouts/review/single.html` template through `.Params.affiliatelink` and `.Params.recommendedby`, respectively.
|
These fields would then be accessible to the `/themes/yourtheme/layouts/review/single.html` template through `.Params.affiliatelink` and `.Params.recommendedby`, respectively.
|
||||||
|
|
||||||
@ -322,37 +317,20 @@ The `.Param` method provides a way to resolve a single value according to it's d
|
|||||||
|
|
||||||
When front matter contains nested fields like the following:
|
When front matter contains nested fields like the following:
|
||||||
|
|
||||||
```yml
|
{{< code-toggle file="content/example.md" fm=true copy=false >}}
|
||||||
---
|
title: Example
|
||||||
author:
|
author:
|
||||||
given_name: John
|
given_name: John
|
||||||
family_name: Feminella
|
family_name: Feminella
|
||||||
display_name: John Feminella
|
display_name: John Feminella
|
||||||
---
|
{{< /code-toggle >}}
|
||||||
```
|
|
||||||
`.Param` can access these fields by concatenating the field names together with a dot:
|
`.Param` can access these fields by concatenating the field names together with a dot:
|
||||||
|
|
||||||
```go-html-template
|
```go-html-template
|
||||||
{{ $.Param "author.display_name" }}
|
{{ $.Param "author.display_name" }}
|
||||||
```
|
```
|
||||||
|
|
||||||
If your front matter contains a top-level key that is ambiguous with a nested key, as in the following case:
|
|
||||||
|
|
||||||
```yml
|
|
||||||
---
|
|
||||||
favorites.flavor: vanilla
|
|
||||||
favorites:
|
|
||||||
flavor: chocolate
|
|
||||||
---
|
|
||||||
```
|
|
||||||
|
|
||||||
The top-level key will be preferred. Therefore, the following method, when applied to the previous example, will print `vanilla` and not `chocolate`:
|
|
||||||
|
|
||||||
```txt
|
|
||||||
{{ $.Param "favorites.flavor" }}
|
|
||||||
=> vanilla
|
|
||||||
```
|
|
||||||
|
|
||||||
[gitinfo]: /variables/git/
|
[gitinfo]: /variables/git/
|
||||||
[File Variables]: /variables/files/
|
[File Variables]: /variables/files/
|
||||||
[bundle]: /content-management/page-bundles
|
[bundle]: /content-management/page-bundles
|
||||||
|
Loading…
x
Reference in New Issue
Block a user