diff --git a/config.toml b/config.toml
index 653e61f7b..25cc01a0d 100644
--- a/config.toml
+++ b/config.toml
@@ -70,7 +70,7 @@ twitter = "GoHugoIO"
[params]
description = "The world’s fastest framework for building websites"
## Used for views in rendered HTML (i.e., rather than using the .Hugo variable)
- release = "0.37.1"
+ release = "0.38.1"
## Setting this to true will add a "noindex" to *EVERY* page on the site
removefromexternalsearch = false
## Gh repo for site footer (include trailing slash)
diff --git a/content/about/new-in-032/index.md b/content/about/new-in-032/index.md
index 41bd58937..b8ca6430e 100644
--- a/content/about/new-in-032/index.md
+++ b/content/about/new-in-032/index.md
@@ -61,7 +61,7 @@ Note that changes to any resource inside the `content` folder will trigger a rel
#### List all Resources
-```html
+```go-html-template
{{ range .Resources }}
{{ end }}
@@ -73,7 +73,7 @@ For an absolute URL, use `.Permalink`.
#### List All Resources by Type
-```html
+```go-html-template
{{ with .Resources.ByType "image" }}
{{ end }}
@@ -83,7 +83,7 @@ Type here is `page` for pages, else the main type in the MIME type, so `image`,
#### Get a Specific Resource
-```html
+```go-html-template
{{ $logo := .Resources.GetByPrefix "logo" }}
{{ with $logo }}
{{ end }}
@@ -91,7 +91,7 @@ Type here is `page` for pages, else the main type in the MIME type, so `image`,
#### Include Page Resource Content
-```html
+```go-html-template
{{ with .Resources.ByType "page" }}
{{ range . }}
{{ .Title }}
@@ -146,7 +146,7 @@ This is the shortcode used in the examples above:
And it is used like this:
-```html
+```go-html-template
{{* imgproc sunset Resize "300x" */>}}
```
diff --git a/content/content-management/comments.md b/content/content-management/comments.md
index 355bf0042..20932a825 100644
--- a/content/content-management/comments.md
+++ b/content/content-management/comments.md
@@ -27,15 +27,11 @@ Hugo comes with all the code you need to load Disqus into your templates. Before
### Configure Disqus
-Disqus comments require you set a single value in your [site's configuration file][configuration]. The following show the configuration variable in a `config.toml` and `config.yml`, respectively:
+Disqus comments require you set a single value in your [site's configuration file][configuration] like so:
-```
+{{< code-toggle copy="false" >}}
disqusShortname = "yourdiscussshortname"
-```
-
-```
-disqusShortname: "yourdiscussshortname"
-```
+{{ code-toggle >}}
For many websites, this is enough configuration. However, you also have the option to set the following in the [front matter][] of a single content file:
diff --git a/content/content-management/front-matter.md b/content/content-management/front-matter.md
index a6a3f2403..2fc18ee31 100644
--- a/content/content-management/front-matter.md
+++ b/content/content-management/front-matter.md
@@ -34,9 +34,9 @@ YAML
JSON
: a single JSON object surrounded by '`{`' and '`}`', followed by a new line.
-### TOML Example
+### Example
-```
+{{< code-toggle >}}
+++
title = "spf13-vim 3.0 release and new website"
description = "spf13-vim is a cross platform distribution of vim plugins and resources for Vim."
@@ -48,39 +48,7 @@ categories = [
]
slug = "spf13-vim-3-0-release-and-new-website"
+++
-```
-
-### YAML Example
-
-```
----
-title: "spf13-vim 3.0 release and new website"
-description: "spf13-vim is a cross platform distribution of vim plugins and resources for Vim."
-tags: [ ".vimrc", "plugins", "spf13-vim", "vim" ]
-lastmod: 2015-12-23
-date: "2012-04-06"
-categories:
- - "Development"
- - "VIM"
-slug: "spf13-vim-3-0-release-and-new-website"
----
-```
-
-### JSON Example
-
-```
-{
- "title": "spf13-vim 3.0 release and new website",
- "description": "spf13-vim is a cross platform distribution of vim plugins and resources for Vim.",
- "tags": [ ".vimrc", "plugins", "spf13-vim", "vim" ],
- "date": "2012-04-06",
- "categories": [
- "Development",
- "VIM"
- ],
- "slug": "spf13-vim-3-0-release-and-new-website"
-}
-```
+{{ code-toggle >}}
## Front Matter Variables
diff --git a/content/content-management/image-processing/index.md b/content/content-management/image-processing/index.md
index 1f84ba04d..ecc85bb51 100644
--- a/content/content-management/image-processing/index.md
+++ b/content/content-management/image-processing/index.md
@@ -23,7 +23,7 @@ The `image` is a [Page Resource]({{< relref "content-management/page-resources"
To get all images in a [Page Bundle]({{< relref "content-management/organization#page-bundles" >}}):
-```html
+```go-html-template
{{ with .Resources.ByType "image" }}
{{ end }}
@@ -131,7 +131,7 @@ This is the shortcode used in the examples above:
And it is used like this:
-```html
+```go-html-template
{{* imgproc sunset Resize "300x" /*/>}}
```
diff --git a/content/content-management/menus.md b/content/content-management/menus.md
index 1353ce0e2..c2eadf50f 100644
--- a/content/content-management/menus.md
+++ b/content/content-management/menus.md
@@ -118,9 +118,9 @@ menu:
You can also add entries to menus that aren’t attached to a piece of content. This takes place in your Hugo project's [`config` file][config].
-Here’s an example snippet pulled from a `config.toml`:
+Here’s an example snippet pulled from a configuration file:
-{{< code file="config.toml" >}}
+{{< code-toggle file="config.toml" >}}
[[menu.main]]
name = "about hugo"
pre = ""
@@ -132,23 +132,7 @@ Here’s an example snippet pulled from a `config.toml`:
pre = ""
weight = -100
url = "/getting-started/"
-{{< /code >}}
-
-Here's the equivalent snippet in a `config.yaml`:
-
-{{< code file="config.yml" >}}
-menu:
- main:
- - name: "about hugo"
- pre: ""
- weight: -110
- identifier: "about"
- url: "/about/"
- - name: "getting started"
- pre: ""
- weight: -100
- url: "/getting-started/"
-{{< /code >}}
+{{< /code-toggle >}}
{{% note %}}
The URLs must be relative to the context root. If the `baseURL` is `https://example.com/mysite/`, then the URLs in the menu must not include the context root `mysite`. Using an absolute URL will override the baseURL. If the value used for `URL` in the above example is `https://subdomain.example.com/`, the output will be `https://subdomain.example.com`.
diff --git a/content/content-management/multilingual.md b/content/content-management/multilingual.md
index 8da599cd2..28a6e4fec 100644
--- a/content/content-management/multilingual.md
+++ b/content/content-management/multilingual.md
@@ -21,9 +21,9 @@ You should define the available languages in a `languages` section in your site
## Configure Languages
-The following is an example of a TOML site configuration for a multilingual Hugo project:
+The following is an example of a site configuration for a multilingual Hugo project:
-{{< code file="config.toml" download="config.toml" >}}
+{{< code-toggle file="config" >}}
DefaultContentLanguage = "en"
copyright = "Everything is mine"
@@ -45,7 +45,7 @@ weight = 2
linkedin = "lien-francais"
[languages.fr.params.navigation]
help = "Aide"
-{{< /code >}}
+{{< /code-toggle >}}
Anything not defined in a `[languages]` block will fall back to the global
value for that key (e.g., `copyright` for the English [`en`] language).
@@ -92,7 +92,7 @@ This means that you can now configure a `baseURL` per `language`:
Example:
-```bash
+{{< code-toggle file="config" >}}
[languages]
[languages.no]
baseURL = "https://example.no"
@@ -105,7 +105,7 @@ baseURL = "https://example.com"
languageName = "English"
weight = 2
title = "In English"
-```
+{{ code-toggle >}}
With the above, the two sites will be generated into `public` with their own root:
@@ -132,7 +132,7 @@ Live reload and `--navigateToChanged` between the servers work as expected.
Taxonomies and [Blackfriday configuration][config] can also be set per language:
-{{< code file="bf-config.toml" >}}
+{{< code-toggle file="config" >}}
[Taxonomies]
tag = "tags"
@@ -152,7 +152,7 @@ weight = 2
title = "Français"
[languages.fr.Taxonomies]
plaque = "plaques"
-{{< /code >}}
+{{ code-toggle >}}
## Translate Your Content
@@ -178,11 +178,6 @@ You can also set the key used to link the translations explicitly in front matte
translationKey: "my-story"
```
-
-{{% note %}}
-**Before Hugo 0.31**, the file's directory was not considered when looking for translations. This did not work when you named all of your content files, say, `index.md`. Now we use the full content path.
-{{% /note %}}
-
If you need distinct URLs per language, you can set the slug in the non-default language file. For example, you can define a custom slug for a French translation in the front matter of `content/about.fr.md` as follows:
```yaml
@@ -192,6 +187,7 @@ slug: "a-propos"
At render, Hugo will build both `/about/` and `/a-propos/` as properly linked translated pages.
+For merging of content from other languages (i.e. missing content translations), see [lang.Merge](/functions/lang.merge/).
## Link to Translated Content
@@ -354,7 +350,7 @@ The rendering of the main navigation works as usual. `.Site.Menus` will just con
```
-## Missing translations
+## Missing Translations
If a string does not have a translation for the current language, Hugo will use the value from the default language. If no default value is set, an empty string will be shown.
@@ -364,6 +360,8 @@ While translating a Hugo website, it can be handy to have a visual indicator of
Hugo will generate your website with these missing translation placeholders. It might not be suited for production environments.
{{% /note %}}
+For merging of content from other languages (i.e. missing content translations), see [lang.Merge](/functions/lang.merge/).
+
## Multilingual Themes support
To support Multilingual mode in your themes, some considerations must be taken for the URLs in the templates. If there is more than one language, URLs must meet the following criteria:
diff --git a/content/content-management/page-bundles.md b/content/content-management/page-bundles.md
index 09aeae8ea..34620a5e2 100644
--- a/content/content-management/page-bundles.md
+++ b/content/content-management/page-bundles.md
@@ -93,7 +93,7 @@ anywhere:
But you can get it by `.Site.GetPage`. Here is an example:
-```html
+```go-html-template
{{ $headless := .Site.GetPage "page" "some-headless-bundle" }}
{{ $reusablePages := $headless.Resources.Match "author*" }}
Authors
diff --git a/content/content-management/page-resources.md b/content/content-management/page-resources.md
index f3b12d8c4..cefb1cd47 100644
--- a/content/content-management/page-resources.md
+++ b/content/content-management/page-resources.md
@@ -83,9 +83,9 @@ params
: A map of custom key/values.
-### Resources metadata: YAML Example
+### Resources metadata example
-~~~yaml
+{{< code-toggle copy="false">}}
title: Application
date : 2018-01-25
resources :
@@ -108,41 +108,7 @@ resources :
- src : "**.docx"
params :
icon : "word"
-~~~
-
-### Resources metadata: TOML Example
-
-~~~toml
-title = Application
-date : 2018-01-25
-[[resources]]
- src = "images/sunset.jpg"
- name = "header"
-[[resources]]
- src = "documents/photo_specs.pdf"
- title = "Photo Specifications"
- [resources.params]
- icon = "photo"
-[[resources]]
- src = "documents/guide.pdf"
- title = "Instruction Guide"
-[[resources]]
- src = "documents/checklist.pdf"
- title = "Document Checklist"
-[[resources]]
- src = "documents/payment.docx"
- title = "Proof of Payment"
-[[resources]]
- src = "**.pdf"
- name = "pdf-file-:counter"
- [resources.params]
- icon = "pdf"
-[[resources]]
- src = "**.docx"
- [resources.params]
- icon = "word"
-~~~
-
+{{ code-toggle >}}
From the example above:
@@ -165,14 +131,14 @@ The counter starts at 1 the first time they are used in either `name` or `title`
For example, if a bundle has the resources `photo_specs.pdf`, `other_specs.pdf`, `guide.pdf` and `checklist.pdf`, and the front matter has specified the `resources` as:
-~~~toml
+{{< code-toggle copy="false">}}
[[resources]]
src = "*specs.pdf"
title = "Specification #:counter"
[[resources]]
src = "**.pdf"
name = "pdf-file-:counter"
-~~~
+{{ code-toggle >}}
the `Name` and `Title` will be assigned to the resource files as follows:
diff --git a/content/content-management/related.md b/content/content-management/related.md
index 8ae6e79ce..6f66e4468 100644
--- a/content/content-management/related.md
+++ b/content/content-management/related.md
@@ -34,6 +34,11 @@ To list up to 5 related pages is as simple as including something similar to thi
{{ end }}
{{< /code >}}
+
+{{% note %}}
+Read [this blog article](https://regisphilibert.com/blog/2018/04/hugo-optmized-relashionships-with-related-content/) for a great explanation more advanced usage of this feature.
+{{% /note %}}
+
The full set of methods available on the page lists can bee seen in this Go interface:
```go
diff --git a/content/content-management/static-files.md b/content/content-management/static-files.md
index 12d27ccf2..fe5ea77e0 100644
--- a/content/content-management/static-files.md
+++ b/content/content-management/static-files.md
@@ -15,11 +15,11 @@ toc: true
The `static` folder is where you place all your **static files**, e.g. stylesheets, JavaScript, images etc.
-You can set the name of the static folder to use in your configuration file, for example `config.toml`. From **Hugo 0.31** you can configure as many static directories as you need. All the files in all the static directories will form a union filesystem.
+You can set the name of the static folder to use in your configuration file. From **Hugo 0.31** you can configure as many static directories as you need. All the files in all the static directories will form a union filesystem.
Example:
-```toml
+{{< code-toggle copy="false" file="config" >}}
staticDir = ["static1", "static2"]
[languages]
[languages.no]
@@ -35,7 +35,7 @@ baseURL = "https://example.com"
languageName = "English"
weight = 2
title = "In English"
-```
+{{ code-toggle >}}
In the above, with no theme used:
diff --git a/content/content-management/syntax-highlighting.md b/content/content-management/syntax-highlighting.md
index 67d443fd4..e7eb011c8 100644
--- a/content/content-management/syntax-highlighting.md
+++ b/content/content-management/syntax-highlighting.md
@@ -147,7 +147,7 @@ See [Highlight](/functions/highlight/).
It is also possible to add syntax highlighting with GitHub flavored code fences. To enable this, set the `pygmentsCodeFences` to `true` in Hugo's [configuration file](/getting-started/configuration/);
````
-```html
+```go-html-template
{{ .Title }}
@@ -159,6 +159,11 @@ It is also possible to add syntax highlighting with GitHub flavored code fences.
```
````
+## List of Chroma Highlighting Languages
+
+The full list of Chroma lexers and their aliases (which is the identifier used in the `hightlight` template func or when doing highlighting in code fences):
+
+{{< chroma-lexers >}}
## Highlight with Pygments Classic
diff --git a/content/content-management/taxonomies.md b/content/content-management/taxonomies.md
index 1a59ebe3e..287c6f899 100644
--- a/content/content-management/taxonomies.md
+++ b/content/content-management/taxonomies.md
@@ -103,23 +103,14 @@ When taxonomies are used---and [taxonomy templates][] are provided---Hugo will a
Taxonomies must be defined in your [website configuration][config] before they can be used throughout the site. You need to provide both the plural and singular labels for each taxonomy. For example, `singular key = "plural value"` for TOML and `singular key: "plural value"` for YAML.
-### Example: TOML Taxonomy Configuration
+### Example: Taxonomy Configuration
-```
+{{< code-toggle copy="false" >}}
[taxonomies]
tag = "tags"
category = "categories"
series = "series"
-```
-
-### Example: YAML Taxonomy Configuration
-
-```
-taxonomies:
- tag: "tags"
- category: "categories"
- series: "series"
-```
+{{ code-toggle >}}
### Preserve Taxonomy Values
@@ -145,53 +136,16 @@ Assigning content to a taxonomy is done in the [front matter][]. Simply create a
If you would like the ability to quickly generate content files with preconfigured taxonomies or terms, read the docs on [Hugo archetypes](/content-management/archetypes/).
{{% /note %}}
-### Example: TOML Front Matter with Taxonomies
+### Example: Front Matter with Taxonomies
-```
-+++
+{{< code-toggle copy="false">}}
title = "Hugo: A fast and flexible static site generator"
tags = [ "Development", "Go", "fast", "Blogging" ]
categories = [ "Development" ]
series = [ "Go Web Dev" ]
slug = "hugo"
project_url = "https://github.com/gohugoio/hugo"
-+++
-```
-
-### Example: YAML Front Matter with Taxonomies
-
-```
----
-title: "Hugo: A fast and flexible static site generator"
-tags: ["Development", "Go", "fast", "Blogging"]
-categories: ["Development"]
-series: ["Go Web Dev"]
-slug: "hugo"
-project_url: "https://github.com/gohugoio/hugo"
----
-```
-
-### Example: JSON Front Matter with Taxonomies
-
-```
-{
- "title": "Hugo: A fast and flexible static site generator",
- "tags": [
- "Development",
- "Go",
- "fast",
- "Blogging"
- ],
- "categories" : [
- "Development"
- ],
- "series" : [
- "Go Web Dev"
- ],
- "slug": "hugo",
- "project_url": "https://github.com/gohugoio/hugo"
-}
-```
+{{ code-toggle >}}
## Order Taxonomies
@@ -199,29 +153,15 @@ A content file can assign weight for each of its associate taxonomies. Taxonomic
The following TOML and YAML examples show a piece of content that has a weight of 22, which can be used for ordering purposes when rendering the pages assigned to the "a", "b" and "c" values of the `tags` taxonomy. It has also been assigned the weight of 44 when rendering the "d" category page.
-### Example: TOML Taxonomic `weight`
+### Example: Taxonomic `weight`
-```
-+++
+{{< code-toggle copy="false" >}}
title = "foo"
tags = [ "a", "b", "c" ]
tags_weight = 22
categories = ["d"]
categories_weight = 44
-+++
-```
-
-### Example: YAML Taxonomic `weight`
-
-```
----
-title: foo
-tags: [ "a", "b", "c" ]
-tags_weight: 22
-categories: ["d"]
-categories_weight: 44
----
-```
+{{ code-toggle >}}
By using taxonomic weight, the same piece of content can appear in different positions in different taxonomies.
diff --git a/content/content-management/urls.md b/content/content-management/urls.md
index dd91fbced..d33725b72 100644
--- a/content/content-management/urls.md
+++ b/content/content-management/urls.md
@@ -29,19 +29,12 @@ These examples use the default values for `publishDir` and `contentDir`; i.e., `
For example, if one of your [sections][] is called `post` and you want to adjust the canonical path to be hierarchical based on the year, month, and post title, you could set up the following configurations in YAML and TOML, respectively.
-### YAML Permalinks Configuration Example
+### Permalinks Configuration Example
-{{< code file="config.yml" copy="false" >}}
+{{< code-toggle file="config" copy="false" >}}
permalinks:
post: /:year/:month/:title/
-{{< /code >}}
-
-### TOML Permalinks Configuration Example
-
-{{< code file="config.toml" copy="false" >}}
-[permalinks]
- post = "/:year/:month/:title/"
-{{< /code >}}
+{{< /code-toggle >}}
Only the content under `post/` will have the new URL structure. For example, the file `content/post/sample-entry.md` with `date: 2017-02-27T19:20:00-05:00` in its front matter will render to `public/2017/02/sample-entry/index.html` at build time and therefore be reachable at `https://example.com/2017/02/sample-entry/`.
diff --git a/content/functions/lang.Merge.md b/content/functions/lang.Merge.md
new file mode 100644
index 000000000..6e1d41c0f
--- /dev/null
+++ b/content/functions/lang.Merge.md
@@ -0,0 +1,47 @@
+---
+title: lang.Merge
+description: "Merge missing translations from other languages."
+godocref: ""
+workson: []
+date: 2018-03-16
+categories: [functions]
+keywords: [multilingual]
+menu:
+ docs:
+ parent: "functions"
+toc: false
+signature: ["lang.Merge FROM TO"]
+workson: []
+hugoversion:
+relatedfuncs: []
+deprecated: false
+draft: false
+aliases: []
+comments:
+---
+
+As an example:
+
+```bash
+{{ $pages := .Site.RegularPages | lang.Merge $frSite.RegularPages | lang.Merge $enSite.RegularPages }}
+```
+
+Will "fill in the gaps" in the current site with, from left to right, content from the French site, and lastly the English.
+
+
+A more practical example is to fill in the missing translations for the "minority languages" with content from the main language:
+
+
+```bash
+ {{ $pages := .Site.RegularPages }}
+ {{ .Scratch.Set "pages" $pages }}
+ {{ $mainSite := .Sites.First }}
+ {{ if ne $mainSite .Site }}
+ {{ .Scratch.Set "pages" ($pages | lang.Merge $mainSite.RegularPages) }}
+ {{ end }}
+ {{ $pages := .Scratch.Get "pages" }}
+ ```
+
+{{% note %}}
+Note that the slightly ugly `.Scratch` construct will not be needed once this is fixed: https://github.com/golang/go/issues/10608
+{{% /note %}}
diff --git a/content/functions/scratch.md b/content/functions/scratch.md
index a827db543..b8fc0e59c 100644
--- a/content/functions/scratch.md
+++ b/content/functions/scratch.md
@@ -32,6 +32,7 @@ See [this Go issue](https://github.com/golang/go/issues/10608) for the main moti
* `Get` returns the `value` for the `key` given.
* `SetInMap` takes a `key`, `mapKey` and `value`
* `GetSortedMapValues` returns array of values from `key` sorted by `mapKey`
+* `Delete` takes a `key` to remove
`Set` and `SetInMap` can store values of any type.
@@ -69,6 +70,11 @@ The usage is best illustrated with some samples:
{{ $.Scratch.SetInMap "a3" "c" "CC" }}
{{ $.Scratch.SetInMap "a3" "b" "BB" }}
{{ $.Scratch.GetSortedMapValues "a3" }} {{/* => []interface {}{"AA", "BB", "CC"} */}}
+
+{{ $.Scratch.Add "a" 1 }}
+{{ $.Scratch.Delete "a" }}
+{{ $.Scratch.Add "a" 2 }}
+{{ $.Scratch.Get "a" }} {{/* => 2 */}}
```
{{% note %}}
diff --git a/content/functions/where.md b/content/functions/where.md
index 3aa03296b..eb3111215 100644
--- a/content/functions/where.md
+++ b/content/functions/where.md
@@ -22,7 +22,7 @@ needsexample: true
`where` filters an array to only the elements containing a matching value for a given field.
-```
+```go-html-template
{{ range where .Data.Pages "Section" "post" }}
{{ .Content }}
{{ end }}
@@ -36,7 +36,7 @@ series: golang
+++
```
-```
+```go-html-template
{{ range where .Site.Pages "Params.series" "golang" }}
{{ .Content }}
{{ end }}
@@ -44,7 +44,7 @@ series: golang
It can also be used with the logical operators `!=`, `>=`, `in`, etc. Without an operator, `where` compares a given field with a matching value equivalent to `=`.
-```
+```go-html-template
{{ range where .Data.Pages "Section" "!=" "post" }}
{{ .Content }}
{{ end }}
@@ -81,7 +81,7 @@ The following logical operators are available with `where`:
## Use `where` with `intersect`
-```
+```go-html-template
{{ range where .Site.Pages ".Params.tags" "intersect" .Params.tags }}
{{ if ne .Permalink $.Permalink }}
{{ .Render "summary" }}
@@ -113,7 +113,7 @@ The following grabs the first five content files in `post` using the [default or
You can also nest `where` clauses to drill down on lists of content by more than one parameter. The following first grabs all pages in the "blog" section and then ranges through the result of the first `where` clause and finds all pages that are *not* featured:
-```
+```go-html-template
{{ range where (where .Data.Pages "Section" "blog" ) ".Params.featured" "!=" "true" }}
```
@@ -128,7 +128,7 @@ Only the following operators are available for `nil`
* `=`, `==`, `eq`: True if the given field is not set.
* `!=`, `<>`, `ne`: True if the given field is set.
-```
+```go-html-template
{{ range where .Data.Pages ".Params.specialpost" "!=" nil }}
{{ .Content }}
{{ end }}
@@ -140,7 +140,7 @@ This is especially important for themes, but to list the most relevant pages on
This will, by default, list pages from the _section with the most pages_.
-```html
+```go-html-template
{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
```
diff --git a/content/getting-started/code-toggle.md b/content/getting-started/code-toggle.md
index ae3e3e84b..3e6b7da0d 100644
--- a/content/getting-started/code-toggle.md
+++ b/content/getting-started/code-toggle.md
@@ -15,7 +15,7 @@ toc: true
This is an exemple for the Config Toggle shortcode.
Its purpose is to let users choose a Config language by clicking on its corresponding tab. Upon doing so, every Code toggler on the page will be switched to the target language. Also, target language will be saved in user's `localStorage` so when they go to a different pages, Code Toggler display their last "toggled" config language.
-## That Congig Toggler
+## That Config Toggler
{{< code-toggle file="config">}}
@@ -72,4 +72,4 @@ blackfriday:
plainIDAnchors: true
extensions:
- hardLineBreak
-{{< /code >}}
\ No newline at end of file
+{{< /code >}}
diff --git a/content/getting-started/configuration.md b/content/getting-started/configuration.md
index f6d4b63a8..8da25fd58 100644
--- a/content/getting-started/configuration.md
+++ b/content/getting-started/configuration.md
@@ -98,6 +98,10 @@ enableMissingTranslationPlaceholders (false)
enableRobotsTXT (false)
: Enable generation of `robots.txt` file.
+frontmatter
+
+: See [Front matter Configuration](#configure-front-matter).
+
footnoteAnchorPrefix ("")
: Prefix for footnote anchors.
@@ -246,9 +250,11 @@ Similar to the template [lookup order][], Hugo has a default set of rules for se
In your `config` file, you can direct Hugo as to how you want your website rendered, control your website's menus, and arbitrarily define site-wide parameters specific to your project.
-## YAML Configuration
+## Example Configuration
-{{< code file="config.yml">}}
+The following is a typical example of a configuration file. The values nested under `params:` will populate the [`.Site.Params`][] variable for use in [templates][]:
+
+{{< code-toggle file="config">}}
baseURL: "https://yoursite.example.com/"
title: "My Hugo Site"
footnoteReturnLinkContents: "↩"
@@ -262,50 +268,7 @@ params:
- "foo1"
- "foo2"
SidebarRecentLimit: 5
-{{< /code >}}
-
-The following is a typical example of a YAML configuration file. The values nested under `params:` will populate the [`.Site.Params`][] variable for use in [templates][]:
-
-{{< code file="config.yml">}}
-baseURL: "https://yoursite.example.com/"
-title: "My Hugo Site"
-footnoteReturnLinkContents: "↩"
-permalinks:
- post: /:year/:month/:title/
-params:
- Subtitle: "Hugo is Absurdly Fast!"
- AuthorName: "Jon Doe"
- GitHubUser: "spf13"
- ListOfFoo:
- - "foo1"
- - "foo2"
- SidebarRecentLimit: 5
-{{< /code >}}
-
-## TOML Configuration
-
-The following is an example of a TOML configuration file. The values under `[params]` will populate the `.Site.Params` variable for use in [templates][]:
-
-{{< code file="config.toml">}}
-contentDir = "content"
-layoutDir = "layouts"
-publishDir = "public"
-buildDrafts = false
-baseURL = "https://yoursite.example.com/"
-canonifyURLs = true
-title = "My Hugo Site"
-
-[taxonomies]
- category = "categories"
- tag = "tags"
-
-[params]
- subtitle = "Hugo is Absurdly Fast!"
- author = "John Doe"
-{{< /code >}}
-
-
-
+{{< /code-toggle >}}
## Configure with Environment Variables
@@ -337,6 +300,67 @@ ignoreFiles = [ "\\.foo$", "\\.boo$" ]
The above is a list of regular expressions. Note that the backslash (`\`) character is escaped in this example to keep TOML happy.
+## Configure Front Matter
+
+### Configure Dates
+
+Dates are important in Hugo, and you can configure how Hugo assigns dates to your content pages. You do this by adding a `frontmatter` section to your `config.toml`.
+
+
+The default configuration is:
+
+```toml
+[frontmatter]
+date = ["date","publishDate", "lastmod"]
+lastmod = [":git" "lastmod", "date","publishDate"]
+publishDate = ["publishDate", "date"]
+expiryDate = ["expiryDate"]
+```
+
+If you, as an example, have a non-standard date parameter in some of your content, you can override the setting for `date`:
+
+ ```toml
+[frontmatter]
+date = [ "myDate", ":default"]
+```
+
+The `:default` is a shortcut to the default settings. The above will set `.Date` to the date value in `myDate` if present, if not we will look in `date`,`publishDate`, `lastmod` and pick the first valid date.
+
+In the list to the right, values starting with ":" are date handlers with a special meaning (see below). The others are just names of date parameters (case insensitive) in your front matter configuration. Also note that Hugo have some built-in aliases to the above: `lastmod` => `modified`, `publishDate` => `pubdate`, `published` and `expiryDate` => `unpublishdate`. With that, as an example, using `pubDate` as a date in front matter, will, by default, be assigned to `.PublishDate`.
+
+The special date handlers are:
+
+
+`:fileModTime`
+: Fetches the date from the content file's last modification timestamp.
+
+An example:
+
+ ```toml
+[frontmatter]
+lastmod = ["lastmod" ,":fileModTime", ":default"]
+```
+
+
+The above will try first to extract the value for `.Lastmod` starting with the `lastmod` front matter parameter, then the content file's modification timestamp. The last, `:default` should not be needed here, but Hugo will finally look for a valid date in `:git`, `date` and then `publishDate`.
+
+
+`:filename`
+: Fetches the date from the content file's filename. For example, `218-02-22-mypage.md` will extract the date `218-02-22`. Also, if `slug is not set, `mypage` will be used as the value for `.Slug`.
+
+An example:
+
+```toml
+[frontmatter]
+date = [":filename", ":default"]
+```
+
+The above will try first to extract the value for `.Date` from the filename, then it will look in front matter parameters `date`, `publishDate` and lastly `lastmod`.
+
+
+`:git`
+: This is the Git author date for the last revision of this content file. This will only be set if `--enableGitInfo` is set or `enableGitInfo = true` is set in site config.
+
## Configure Blackfriday
[Blackfriday](https://github.com/russross/blackfriday) is Hugo's built-in Markdown rendering engine.
@@ -352,22 +376,13 @@ However, if you have specific needs with respect to Markdown, Hugo exposes some
2. Blackfriday flags must be grouped under the `blackfriday` key and can be set on both the site level *and* the page level. Any setting on a page will override its respective site setting.
{{% /note %}}
-{{< code file="bf-config.toml" >}}
+{{< code-toggle file="config" >}}
[blackfriday]
angledQuotes = true
fractions = false
plainIDAnchors = true
extensions = ["hardLineBreak"]
-{{< /code >}}
-
-{{< code file="bf-config.yml" >}}
-blackfriday:
- angledQuotes: true
- fractions: false
- plainIDAnchors: true
- extensions:
- - hardLineBreak
-{{< /code >}}
+{{< /code-toggle >}}
## Configure Additional Output Formats
diff --git a/content/news/0.27-relnotes-ready.md b/content/news/0.27-relnotes-ready.md
index 3dd02d455..9251c3768 100644
--- a/content/news/0.27-relnotes-ready.md
+++ b/content/news/0.27-relnotes-ready.md
@@ -9,7 +9,7 @@ categories: ["Releases"]
Hugo `0.27`comes with fast and flexible **Related Content** ([3b4f17bb](https://github.com/gohugoio/hugo/commit/3b4f17bbc9ff789faa581ac278ad109d1ac5b816) [@bep](https://github.com/bep) [#98](https://github.com/gohugoio/hugo/issues/98)). To add this to your site, put something like this in your single page template:
-```html
+```go-html-template
{{ $related := .Site.RegularPages.Related . | first 5 }}
{{ with $related }}
See Also
diff --git a/content/news/0.27-relnotes.md b/content/news/0.27-relnotes.md
index a4ead0816..92fc3a7b0 100644
--- a/content/news/0.27-relnotes.md
+++ b/content/news/0.27-relnotes.md
@@ -11,7 +11,7 @@ images:
Hugo `0.27`comes with fast and flexible **Related Content** ([3b4f17bb](https://github.com/gohugoio/hugo/commit/3b4f17bbc9ff789faa581ac278ad109d1ac5b816) [@bep](https://github.com/bep) [#98](https://github.com/gohugoio/hugo/issues/98)). To add this to your site, put something like this in your single page template:
-```html
+```go-html-template
{{ $related := .Site.RegularPages.Related . | first 5 }}
{{ with $related }}