Merge commit '8d9511a08f14260cbfb73119e4afae50e5a9966d'

This commit is contained in:
Bjørn Erik Pedersen 2021-12-08 08:54:25 +01:00
commit 6c841a691e
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
48 changed files with 463 additions and 465 deletions

View file

@ -65,7 +65,7 @@ audio
: an array of paths to audio files related to the page; used by the `opengraph` [internal template](/templates/internal) to populate `og:audio`. : an array of paths to audio files related to the page; used by the `opengraph` [internal template](/templates/internal) to populate `og:audio`.
cascade cascade
: a map of Front Matter keys whose values are passed down to the page's descendents unless overwritten by self or a closer ancestor's cascade. See [Front Matter Cascade](#front-matter-cascade) for details. : 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 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 behaviour is configurable.
@ -128,8 +128,7 @@ type
: the type of the content; this value will be automatically derived from the directory (i.e., the [section][]) if not specified in front matter. : the type of the content; this value will be automatically derived from the directory (i.e., the [section][]) if not specified in front matter.
url url
: the full path to the content from the web root. It makes no assumptions about the path of the content file. It also ignores any language prefixes of : the full path to the content from the web root. It makes no assumptions about the path of the content file. See [URL Management](/content-management/urls/#set-url-in-front-matter).
the multilingual feature.
videos videos
: an array of paths to videos related to the page; used by the `opengraph` [internal template](/templates/internal) to populate `og:video`. : an array of paths to videos related to the page; used by the `opengraph` [internal template](/templates/internal) to populate `og:video`.
@ -157,7 +156,7 @@ show_comments: false
## Front Matter Cascade ## Front Matter Cascade
Any node or section can pass down to descendents a set of Front Matter values as long as defined underneath the reserved `cascade` Front Matter key. Any node or section can pass down to descendants a set of Front Matter values as long as defined underneath the reserved `cascade` Front Matter key.
### Target Specific Pages ### Target Specific Pages
@ -202,9 +201,9 @@ cascade:
banner: images/typewriter.jpg banner: images/typewriter.jpg
{{</ code-toggle >}} {{</ code-toggle >}}
With the above example the Blog section page and its descendents will return `images/typewriter.jpg` when `.Params.banner` is invoked unless: With the above example the Blog section page and its descendants will return `images/typewriter.jpg` when `.Params.banner` is invoked unless:
- Said descendent 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. - Or a closer ancestor node has its own `cascade.banner` value set.

View file

@ -229,7 +229,7 @@ See https://github.com/disintegration/imaging for more. If you want to trade qua
By default the images is encoded in the source format, but you can set the target format as an option. By default the images is encoded in the source format, but you can set the target format as an option.
Valid values are `jpg`, `png`, `tif`, `bmp`, `gif` and `webp`. Valid values are `bmp`, `gif`, `jpeg`, `jpg`, `png`, `tif`, `tiff`, and `webp`.
```go ```go
{{ $image.Resize "600x jpg" }} {{ $image.Resize "600x jpg" }}

View file

@ -12,7 +12,7 @@ menu:
docs: docs:
parent: "content-management" parent: "content-management"
weight: 120 weight: 120
weight: 120 #rem weight: 120
aliases: [/extras/menus/] aliases: [/extras/menus/]
toc: true toc: true
--- ---
@ -48,31 +48,24 @@ If all you need to do is add an entry to a menu, the simple form works well.
#### A Single Menu #### A Single Menu
``` {{< code-toggle >}}
---
menu: "main" menu: "main"
--- {{< /code-toggle >}}
```
#### Multiple Menus #### Multiple Menus
``` {{< code-toggle >}}
---
menu: ["main", "footer"] menu: ["main", "footer"]
--- {{< /code-toggle >}}
```
#### Advanced #### Advanced
{{< code-toggle >}}
```
---
menu: menu:
docs: docs:
parent: 'extras' parent: 'extras'
weight: 20 weight: 20
--- {{< /code-toggle >}}
```
## Add Non-content Entries to a Menu ## Add Non-content Entries to a Menu
@ -115,7 +108,7 @@ In this example, the top level of the menu is defined in your [site `config` fil
## Params ## Params
You can also add user-defined content to menu items via the `params` field. You can also add user-defined content to menu items via the `params` field.
A common use case is to define a custom param to add a css class to a specific menu item. A common use case is to define a custom param to add a css class to a specific menu item.
@ -130,7 +123,6 @@ A common use case is to define a custom param to add a css class to a specific m
class = "highlight-menu-item" class = "highlight-menu-item"
{{</ code-toggle >}} {{</ code-toggle >}}
## Render Menus ## Render Menus
See [Menu Templates](/templates/menu-templates/) for information on how to render your site menus within your templates. See [Menu Templates](/templates/menu-templates/) for information on how to render your site menus within your templates.

View file

@ -19,7 +19,7 @@ toc: true
You should define the available languages in a `languages` section in your site configuration. You should define the available languages in a `languages` section in your site configuration.
> Also See [Hugo Multilingual Part 1: Content translation](https://regisphilibert.com/blog/2018/08/hugo-multilingual-part-1-managing-content-translation/) > Also See [Hugo Multilingual Part 1: Content translation]
## Configure Languages ## Configure Languages
@ -63,7 +63,7 @@ Anything not defined in a `languages` block will fall back to the global value f
With the configuration above, all content, sitemap, RSS feeds, paginations, With the configuration above, all content, sitemap, RSS feeds, paginations,
and taxonomy pages will be rendered below `/` in English (your default content language) and then below `/fr` in French. and taxonomy pages will be rendered below `/` in English (your default content language) and then below `/fr` in French.
When working with front matter `Params` in [single page templates][singles], omit the `params` in the key for the translation. When working with front matter `Params` in [single page templates], omit the `params` in the key for the translation.
`defaultContentLanguage` sets the project's default language. If not set, the default language will be `en`. `defaultContentLanguage` sets the project's default language. If not set, the default language will be `en`.
@ -83,25 +83,24 @@ disableLanguages = ["fr", "ja"]
Note that you cannot disable the default content language. Note that you cannot disable the default content language.
We kept this as a standalone setting to make it easier to set via [OS environment](/getting-started/configuration/#configure-with-environment-variables): We kept this as a standalone setting to make it easier to set via [OS environment]:
```bash ```bash
HUGO_DISABLELANGUAGES="fr ja" hugo HUGO_DISABLELANGUAGES="fr ja" hugo
``` ```
If you have already a list of disabled languages in `config.toml`, you can enable them in development like this: If you have already a list of disabled languages in `config.toml`, you can enable them in development like this:
```bash ```bash
HUGO_DISABLELANGUAGES=" " hugo server HUGO_DISABLELANGUAGES=" " hugo server
``` ```
### Configure Multilingual Multihost ### Configure Multilingual Multihost
From **Hugo 0.31** we support multiple languages in a multihost configuration. See [this issue](https://github.com/gohugoio/hugo/issues/4027) for details. From **Hugo 0.31** we support multiple languages in a multihost configuration. See [this issue](https://github.com/gohugoio/hugo/issues/4027) for details.
This means that you can now configure a `baseURL` per `language`: This means that you can now configure a `baseURL` per `language`:
> If a `baseURL` is set on the `language` level, then all languages must have one and they must all be different. > If a `baseURL` is set on the `language` level, then all languages must have one and they must all be different.
Example: Example:
@ -123,7 +122,7 @@ title = "In English"
With the above, the two sites will be generated into `public` with their own root: With the above, the two sites will be generated into `public` with their own root:
```bash ```text
public public
├── en ├── en
└── fr └── fr
@ -133,7 +132,7 @@ public
When you run `hugo server` we will start multiple HTTP servers. You will typically see something like this in the console: When you run `hugo server` we will start multiple HTTP servers. You will typically see something like this in the console:
```bash ```text
Web Server is available at 127.0.0.1:1313 (bind address 127.0.0.1) Web Server is available at 127.0.0.1:1313 (bind address 127.0.0.1)
Web Server is available at 127.0.0.1:1314 (bind address 127.0.0.1) Web Server is available at 127.0.0.1:1314 (bind address 127.0.0.1)
Press Ctrl+C to stop Press Ctrl+C to stop
@ -145,7 +144,6 @@ Live reload and `--navigateToChanged` between the servers work as expected.
Taxonomies and [Blackfriday configuration][config] can also be set per language: Taxonomies and [Blackfriday configuration][config] can also be set per language:
{{< code-toggle file="config" >}} {{< code-toggle file="config" >}}
[Taxonomies] [Taxonomies]
tag = "tags" tag = "tags"
@ -182,7 +180,7 @@ Considering the following example:
The first file is assigned the English language and is linked to the second. The first file is assigned the English language and is linked to the second.
The second file is assigned the French language and is linked to the first. The second file is assigned the French language and is linked to the first.
Their language is __assigned__ according to the language code added as a __suffix to the filename__. Their language is __assigned__ according to the language code added as a __suffix to the filename__.
By having the same **path and base filename**, the content pieces are __linked__ together as translated pages. By having the same **path and base filename**, the content pieces are __linked__ together as translated pages.
@ -195,7 +193,6 @@ If a file has no language code, it will be assigned the default language.
This system uses different content directories for each of the languages. Each language's content directory is set using the `contentDir` param. This system uses different content directories for each of the languages. Each language's content directory is set using the `contentDir` param.
{{< code-toggle file="config" >}} {{< code-toggle file="config" >}}
languages: languages:
en: en:
weight: 10 weight: 10
@ -205,7 +202,6 @@ languages:
weight: 20 weight: 20
languageName: "Français" languageName: "Français"
contentDir: "content/french" contentDir: "content/french"
{{< /code-toggle >}} {{< /code-toggle >}}
The value of `contentDir` can be any valid path -- even absolute path references. The only restriction is that the content directories cannot overlap. The value of `contentDir` can be any valid path -- even absolute path references. The only restriction is that the content directories cannot overlap.
@ -222,7 +218,7 @@ Their language is __assigned__ according to the content directory they are __pla
By having the same **path and basename** (relative to their language content directory), the content pieces are __linked__ together as translated pages. By having the same **path and basename** (relative to their language content directory), the content pieces are __linked__ together as translated pages.
### Bypassing default linking. ### Bypassing default linking
Any pages sharing the same `translationKey` set in front matter will be linked as translated pages regardless of basename or location. Any pages sharing the same `translationKey` set in front matter will be linked as translated pages regardless of basename or location.
@ -232,19 +228,17 @@ Considering the following example:
2. `/content/om.nn.md` 2. `/content/om.nn.md`
3. `/content/presentation/a-propos.fr.md` 3. `/content/presentation/a-propos.fr.md`
```yaml {{< code-toggle >}}
# set in all three pages
translationKey: "about" translationKey: "about"
``` {{< /code-toggle >}}
By setting the `translationKey` front matter param to `about` in all three pages, they will be __linked__ as translated pages. By setting the `translationKey` front matter param to `about` in all three pages, they will be __linked__ as translated pages.
### Localizing permalinks ### Localizing permalinks
Because paths and filenames are used to handle linking, all translated pages will share the same URL (apart from the language subdirectory). Because paths and filenames are used to handle linking, all translated pages will share the same URL (apart from the language subdirectory).
To localize the URLs, the [`slug`]({{< ref "/content-management/organization/index.md#slug" >}}) or [`url`]({{< ref "/content-management/organization/index.md#url" >}}) front matter param can be set in any of the non-default language file. To localize the URLs, the [`slug`]({{< ref "/content-management/organization/index.md#slug" >}}) or [`url`]({{< ref "/content-management/organization/index.md#url" >}}) front matter param can be set in any of the non-default language file.
For example, a French translation (`content/about.fr.md`) can have its own localized slug. For example, a French translation (`content/about.fr.md`) can have its own localized slug.
@ -253,7 +247,6 @@ Title: A Propos
slug: "a-propos" slug: "a-propos"
{{< /code-toggle >}} {{< /code-toggle >}}
At render, Hugo will build both `/about/` and `/fr/a-propos/` while maintaining their translation linking. At render, Hugo will build both `/about/` and `/fr/a-propos/` while maintaining their translation linking.
{{% note %}} {{% note %}}
@ -283,16 +276,16 @@ To create a list of links to translated content, use a template similar to the f
{{ if .IsTranslated }} {{ if .IsTranslated }}
<h4>{{ i18n "translations" }}</h4> <h4>{{ i18n "translations" }}</h4>
<ul> <ul>
{{ range .Translations }} {{ range .Translations }}
<li> <li>
<a href="{{ .Permalink }}">{{ .Lang }}: {{ .Title }}{{ if .IsPage }} ({{ i18n "wordCount" . }}){{ end }}</a> <a href="{{ .Permalink }}">{{ .Lang }}: {{ .Title }}{{ if .IsPage }} ({{ i18n "wordCount" . }}){{ end }}</a>
</li> </li>
{{ end }} {{ end }}
</ul> </ul>
{{ end }} {{ end }}
{{< /code >}} {{< /code >}}
The above can be put in a `partial` (i.e., inside `layouts/partials/`) and included in any template, whether a [single content page][contenttemplate] or the [homepage][]. It will not print anything if there are no translations for a given page. The above can be put in a `partial` (i.e., inside `layouts/partials/`) and included in any template, whether a [single content page][contenttemplate] or the [homepage]. It will not print anything if there are no translations for a given page.
The above also uses the [`i18n` function][i18func] described in the next section. The above also uses the [`i18n` function][i18func] described in the next section.
@ -300,7 +293,6 @@ The above also uses the [`i18n` function][i18func] described in the next section
`.AllTranslations` on a `Page` can be used to list all translations, including the page itself. On the home page it can be used to build a language navigator: `.AllTranslations` on a `Page` can be used to list all translations, including the page itself. On the home page it can be used to build a language navigator:
{{< code file="layouts/partials/allLanguages.html" >}} {{< code file="layouts/partials/allLanguages.html" >}}
<ul> <ul>
{{ range $.Site.Home.AllTranslations }} {{ range $.Site.Home.AllTranslations }}
@ -311,22 +303,24 @@ The above also uses the [`i18n` function][i18func] described in the next section
## Translation of Strings ## Translation of Strings
Hugo uses [go-i18n][] to support string translations. [See the project's source repository][go-i18n-source] to find tools that will help you manage your translation workflows. Hugo uses [go-i18n] to support string translations. [See the project's source repository][go-i18n-source] to find tools that will help you manage your translation workflows.
Translations are collected from the `themes/<THEME>/i18n/` folder (built into the theme), as well as translations present in `i18n/` at the root of your project. In the `i18n`, the translations will be merged and take precedence over what is in the theme folder. Language files should be named according to [RFC 5646][] with names such as `en-US.toml`, `fr.toml`, etc. Translations are collected from the `themes/<THEME>/i18n/` folder (built into the theme), as well as translations present in `i18n/` at the root of your project. In the `i18n`, the translations will be merged and take precedence over what is in the theme folder. Language files should be named according to [RFC 5646] with names such as `en-US.toml`, `fr.toml`, etc.
{{% note %}} Artificial languages with private use subtags as defined in [RFC 5646 &#167; 2.2.7](https://datatracker.ietf.org/doc/html/rfc5646#section-2.2.7) are also supported. You may omit the `art-x-` prefix for brevity. For example:
From **Hugo 0.31** you no longer need to use a valid language code. It can be anything.
See https://github.com/gohugoio/hugo/issues/3564 ```text
art-x-hugolang
hugolang
```
{{% /note %}} Private use subtags must not exceed 8 alphanumeric characters.
### Query basic translation ### Query basic translation
From within your templates, use the `i18n` function like this: From within your templates, use the `i18n` function like this:
``` ```go-html-template
{{ i18n "home" }} {{ i18n "home" }}
``` ```
@ -339,7 +333,7 @@ other = "Home"
The result will be The result will be
``` ```text
Home Home
``` ```
@ -347,7 +341,7 @@ Home
Often you will want to use the page variables in the translation strings. To do so, pass the `.` context when calling `i18n`: Often you will want to use the page variables in the translation strings. To do so, pass the `.` context when calling `i18n`:
``` ```go-html-template
{{ i18n "wordCount" . }} {{ i18n "wordCount" . }}
``` ```
@ -360,7 +354,7 @@ other = "This article has {{ .WordCount }} words."
Assume `.WordCount` in the context has value is 101. The result will be: Assume `.WordCount` in the context has value is 101. The result will be:
``` ```text
This article has 101 words. This article has 101 words.
``` ```
@ -368,7 +362,7 @@ This article has 101 words.
In order to meet singular/plural requirement, you must pass a dictionary (map) with a numeric `.Count` property to the `i18n` function. The below example uses `.ReadingTime` variable which has a built-in `.Count` property. In order to meet singular/plural requirement, you must pass a dictionary (map) with a numeric `.Count` property to the `i18n` function. The below example uses `.ReadingTime` variable which has a built-in `.Count` property.
``` ```go-html-template
{{ i18n "readingTime" .ReadingTime }} {{ i18n "readingTime" .ReadingTime }}
``` ```
@ -382,52 +376,122 @@ other = "{{.Count}} minutes to read"
Assume `.ReadingTime.Count` in the context has value of 525600. The result will be: Assume `.ReadingTime.Count` in the context has value of 525600. The result will be:
``` ```text
525600 minutes to read 525600 minutes to read
``` ```
If `.ReadingTime.Count` in the context has value is 1. The result is: If `.ReadingTime.Count` in the context has value is 1. The result is:
``` ```text
One minute to read One minute to read
``` ```
In case you need to pass custom data: (`(dict "Count" 25)` is minimum requirement) In case you need to pass custom data: (`(dict "Count" 25)` is minimum requirement)
``` ```go-html-template
{{ i18n "readingTime" (dict "Count" 25 "FirstArgument" true "SecondArgument" false "Etc" "so on, so far") }} {{ i18n "readingTime" (dict "Count" 25 "FirstArgument" true "SecondArgument" false "Etc" "so on, so far") }}
``` ```
## Localization
## Customize Dates The following localization examples assume your site's primary language is English, with translations to French and German.
At the time of this writing, Go does not yet have support for internationalized locales for dates, but if you do some work, you can simulate it. For example, if you want to use French month names, you can add a data file like ``data/mois.yaml`` with this content: {{< code-toggle file="config" >}}
defaultContentLang = 'en'
~~~yaml [languages]
1: "janvier" [languages.en]
2: "février" contentDir = 'content/en'
3: "mars" languageName = 'English'
4: "avril" weight = 1
5: "mai" [languages.fr]
6: "juin" contentDir = 'content/fr'
7: "juillet" languageName = 'Français'
8: "août" weight = 2
9: "septembre" [languages.de]
10: "octobre" contentDir = 'content/de'
11: "novembre" languageName = 'Deutsch'
12: "décembre" weight = 3
~~~
...then index the non-English date names in your templates like so: {{< /code-toggle >}}
~~~html ### Dates
<time class="post-date" datetime="{{ .Date.Format `2006-01-02T15:04:05Z07:00` | safeHTML }}">
Article publié le {{ .Date.Day }} {{ index $.Site.Data.mois (printf "%d" .Date.Month) }} {{ .Date.Year }} (dernière modification le {{ .Lastmod.Day }} {{ index $.Site.Data.mois (printf "%d" .Lastmod.Month) }} {{ .Lastmod.Year }})
</time>
~~~
This technique extracts the day, month and year by specifying ``.Date.Day``, ``.Date.Month``, and ``.Date.Year``, and uses the month number as a key, when indexing the month name data file. With this front matter:
{{< code-toggle >}}
date = 2021-11-03T12:34:56+01:00
{{< /code-toggle >}}
And this template code:
```go-html-template
{{ .Date | time.Format ":date_full" }}
```
The rendered page displays:
Language|Value
:--|:--
English|Wednesday, November 3, 2021
Français|mercredi 3 novembre 2021
Deutsch|Mittwoch, 3. November 2021
See [time.Format] for details.
### Currency
With this template code:
```go-html-template
{{ 512.5032 | lang.FormatCurrency 2 "USD" }}
```
The rendered page displays:
Language|Value
:--|:--
English|$512.50
Français|512,50 $US
Deutsch|512,50 $
See [lang.FormatCurrency] and [lang.FormatAccounting] for details.
### Numbers
With this template code:
```go-html-template
{{ 512.5032 | lang.FormatNumber 2 }}
```
The rendered page displays:
Language|Value
:--|:--
English|512.50
Français|512,50
Deutsch|512,50
See [lang.FormatNumber] and [lang.FormatNumberCustom] for details.
### Percentages
With this template code:
```go-html-template
{{ 512.5032 | lang.FormatPercent 2 }} ---> 512.50%
```
The rendered page displays:
Language|Value
:--|:--
English|512.50%
Français|512,50 %
Deutsch|512,50 %
See [lang.FormatPercent] for details.
## Menus ## Menus
@ -445,7 +509,6 @@ url = "/"
name = "Home" name = "Home"
weight = 0 weight = 0
[languages.de] [languages.de]
weight = 10 weight = 10
languageName = "Deutsch" languageName = "Deutsch"
@ -458,7 +521,7 @@ weight = 0
The rendering of the main navigation works as usual. `.Site.Menus` will just contain the menu in the current language. Note that `absLangURL` below will link to the correct locale of your website. Without it, menu entries in all languages would link to the English version, since it's the default content language that resides in the root directory. The rendering of the main navigation works as usual. `.Site.Menus` will just contain the menu in the current language. Note that `absLangURL` below will link to the correct locale of your website. Without it, menu entries in all languages would link to the English version, since it's the default content language that resides in the root directory.
``` ```go-html-template
<ul> <ul>
{{- $currentPage := . -}} {{- $currentPage := . -}}
{{ range .Site.Menus.main -}} {{ range .Site.Menus.main -}}
@ -467,7 +530,6 @@ The rendering of the main navigation works as usual. `.Site.Menus` will just con
</li> </li>
{{- end }} {{- end }}
</ul> </ul>
``` ```
## Missing Translations ## Missing Translations
@ -480,12 +542,12 @@ 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 suitable for production environments. Hugo will generate your website with these missing translation placeholders. It might not be suitable for production environments.
{{% /note %}} {{% /note %}}
For merging of content from other languages (i.e. missing content translations), see [lang.Merge](/functions/lang.merge/). For merging of content from other languages (i.e. missing content translations), see [lang.Merge].
To track down missing translation strings, run Hugo with the `--i18n-warnings` flag: To track down missing translation strings, run Hugo with the `--i18n-warnings` flag:
``` ```bash
hugo --i18n-warnings | grep i18n hugo --i18n-warnings | grep i18n
i18n|MISSING_TRANSLATION|en|wordCount i18n|MISSING_TRANSLATION|en|wordCount
``` ```
@ -504,8 +566,17 @@ If there is more than one language defined, the `LanguagePrefix` variable will e
[go-i18n-source]: https://github.com/nicksnyder/go-i18n [go-i18n-source]: https://github.com/nicksnyder/go-i18n
[go-i18n]: https://github.com/nicksnyder/go-i18n [go-i18n]: https://github.com/nicksnyder/go-i18n
[homepage]: /templates/homepage/ [homepage]: /templates/homepage/
[Hugo Multilingual Part 1: Content translation]: https://regisphilibert.com/blog/2018/08/hugo-multilingual-part-1-managing-content-translation/
[i18func]: /functions/i18n/ [i18func]: /functions/i18n/
[lang.FormatAccounting]: /functions/lang/#langformataccounting
[lang.FormatCurrency]: /functions/lang/#langformatcurrency
[lang.FormatNumber]: /functions/lang/#langformatnumber
[lang.FormatNumberCustom]: functions/lang/#langformatnumbercustom
[lang.FormatPercent]: /functions/lang/#langformatpercent
[lang.Merge]: /functions/lang.merge/
[menus]: /content-management/menus/ [menus]: /content-management/menus/
[OS environment]: /getting-started/configuration/#configure-with-environment-variables
[rellangurl]: /functions/rellangurl [rellangurl]: /functions/rellangurl
[RFC 5646]: https://tools.ietf.org/html/rfc5646 [RFC 5646]: https://tools.ietf.org/html/rfc5646
[singles]: /templates/single-page-templates/ [single page templates]: /templates/single-page-templates/
[time.Format]: /functions/dateformat

View file

@ -24,12 +24,12 @@ Hugo `0.32` announced page-relative images and other resources packaged into `Pa
These terms are connected, and you also need to read about [Page Resources]({{< relref "/content-management/page-resources" >}}) and [Image Processing]({{< relref "/content-management/image-processing" >}}) to get the full picture. These terms are connected, and you also need to read about [Page Resources]({{< relref "/content-management/page-resources" >}}) and [Image Processing]({{< relref "/content-management/image-processing" >}}) to get the full picture.
{{< imgproc 1-featured Resize "300x" >}} {{< imgproc 1-featured Resize "300x" >}}
The illustration shows 3 bundles. Note that the home page bundle cannot contain other content pages, but other files (images etc.) are fine. The illustration shows three bundles. Note that the home page bundle cannot contain other content pages, although other files (images etc.) are allowed.
{{< /imgproc >}} {{< /imgproc >}}
{{% note %}} {{% note %}}
The bundle documentation is **work in progress**. We will publish more comprehensive docs about this soon. The bundle documentation is a **work in progress**. We will publish more comprehensive docs about this soon.
{{% /note %}} {{% /note %}}
@ -40,7 +40,7 @@ In Hugo, your content should be organized in a manner that reflects the rendered
While Hugo supports content nested at any level, the top levels (i.e. `content/<DIRECTORIES>`) are special in Hugo and are considered the content type used to determine layouts etc. To read more about sections, including how to nest them, see [sections][]. While Hugo supports content nested at any level, the top levels (i.e. `content/<DIRECTORIES>`) are special in Hugo and are considered the content type used to determine layouts etc. To read more about sections, including how to nest them, see [sections][].
Without any additional configuration, the following will just work: Without any additional configuration, the following will automatically work:
``` ```
. .
@ -70,7 +70,7 @@ The following demonstrates the relationships between your content organization a
**Tip:** You can get a reference to the content and metadata in `_index.md` using the [`.Site.GetPage` function](/functions/getpage/). **Tip:** You can get a reference to the content and metadata in `_index.md` using the [`.Site.GetPage` function](/functions/getpage/).
{{% /note %}} {{% /note %}}
You can keep one `_index.md` for your homepage and one in each of your content sections, taxonomies, and taxonomy terms. The following shows typical placement of an `_index.md` that would contain content and front matter for a `posts` section list page on a Hugo website: You can create one `_index.md` for your homepage and one in each of your content sections, taxonomies, and taxonomy terms. The following shows typical placement of an `_index.md` that would contain content and front matter for a `posts` section list page on a Hugo website:
``` ```
@ -96,12 +96,12 @@ At build, this will output to the following destination with the associated valu
https://example.com/posts/index.html https://example.com/posts/index.html
``` ```
The [sections][] can be nested as deeply as you need. The important part to understand is, that to make the section tree fully navigational, at least the lower-most section needs a content file. (i.e. `_index.md`). The [sections] can be nested as deeply as you want. The important thing to understand is that to make the section tree fully navigational, at least the lower-most section must include a content file. (i.e. `_index.md`).
### Single Pages in Sections ### Single Pages in Sections
Single content files in each of your sections are going to be rendered as [single page templates][singles]. Here is an example of a single `post` within `posts`: Single content files in each of your sections will be rendered as [single page templates][singles]. Here is an example of a single `post` within `posts`:
``` ```
@ -112,7 +112,7 @@ Single content files in each of your sections are going to be rendered as [singl
content/posts/my-first-hugo-post.md content/posts/my-first-hugo-post.md
``` ```
When Hugo builds your site, the content will be outputted to the following destination: When Hugo builds your site, the content will be output to the following destination:
``` ```
@ -128,11 +128,11 @@ https://example.com/posts/my-first-hugo-post/index.html
## Paths Explained ## Paths Explained
The following concepts will provide more insight into the relationship between your project's organization and the default behaviors of Hugo when building the output website. The following concepts provide more insight into the relationship between your project's organization and the default Hugo behavior when building output for the website.
### `section` ### `section`
A default content type is determined by a piece of content's section. `section` is determined by the location within the project's `content` directory. `section` *cannot* be specified or overridden in front matter. A default content type is determined by the section in which a content item is stored. `section` is determined by the location within the project's `content` directory. `section` *cannot* be specified or overridden in front matter.
### `slug` ### `slug`
@ -152,24 +152,24 @@ A content's `path` is determined by the section's path to the file. The file `pa
The `url` is the relative URL for the piece of content. The `url` The `url` is the relative URL for the piece of content. The `url`
* is based on the content's location within the directory structure OR * is based on the content item's location within the directory structure OR
* is defined in front matter and *overrides all the above* * is defined in front matter, in which case it *overrides all the above*
## Override Destination Paths via Front Matter ## Override Destination Paths via Front Matter
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. As displayed above, the organization of the source content will be mirrored in the destination. Hugo assumes that your content is organized with a purpose. The same structure that you use to organize your source content is used to organize the rendered site. As displayed above, the organization of the source content will be mirrored at the destination.
There are times where you may need more control over your content. In these cases, there are fields that can be specified in the front matter to determine the destination of a specific piece of content. There are times when you may need more fine-grained control over the content organization. In such cases, the front matter field can be used to determine the destination of a specific piece of content.
The following items are defined in this order for a specific reason: items explained further down in the list will override earlier items, and not all of these items can be defined in front matter: The following items are defined in a specific order for a reason: items explained lower down in the list override higher items. Note that not all items can be defined in front matter.
### `filename` ### `filename`
This isn't in the front matter, but is the actual name of the file minus the extension. This will be the name of the file in the destination (e.g., `content/posts/my-post.md` becomes `example.com/posts/my-post/`). `filename` is not a front matter field. It is the actual file name, minus the extension. This will be the name of the file in the destination (e.g., `content/posts/my-post.md` becomes `example.com/posts/my-post/`).
### `slug` ### `slug`
When defined in the front matter, the `slug` can take the place of the filename for the destination. When defined in the front matter, the `slug` can take the place of the filename in the destination.
{{< code file="content/posts/old-post.md" >}} {{< code file="content/posts/old-post.md" >}}
--- ---
@ -186,11 +186,11 @@ example.com/posts/new-post/
### `section` ### `section`
`section` is determined by a content's location on disk and *cannot* be specified in the front matter. See [sections][] for more information. `section` is determined by a content item's location on disk and *cannot* be specified in the front matter. See [sections] for more information.
### `type` ### `type`
A content's `type` is also determined by its location on disk but, unlike `section`, it *can* be specified in the front matter. See [types][]. This can come in especially handy when you want a piece of content to render using a different layout. In the following example, you can create a layout at `layouts/new/mylayout.html` that Hugo will use to render this piece of content, even in the midst of many other posts. A content item's `type` is also determined by its location on disk but, unlike `section`, it *can* be specified in the front matter. See [types]. This can come in especially handy when you want a piece of content to render using a different layout. In the following example, you can create a layout at `layouts/new/mylayout.html` that Hugo will use to render this piece of content, even in the midst of many other posts.
{{< code file="content/posts/my-post.md" >}} {{< code file="content/posts/my-post.md" >}}
--- ---
@ -206,7 +206,7 @@ layout: mylayout
### `url` ### `url`
A complete URL can be provided. This will override all the above as it pertains to the end destination. This must be the path from the baseURL (starting with a `/`). `url` will be used exactly as it provided in the front matter and will ignore the `--uglyURLs` setting in your site configuration: A complete URL can be provided. This will override all the above as it pertains to the end destination. This must be the path from the baseURL (starting with a `/`). `url` will be used exactly as it is defined in the front matter, and will ignore the `--uglyURLs` setting in your site configuration:
{{< code file="content/posts/old-url.md" >}} {{< code file="content/posts/old-url.md" >}}
--- ---

View file

@ -60,7 +60,22 @@ RelPermalink
: The relative URL to the resource. Resources of type `page` will have no value. : The relative URL to the resource. Resources of type `page` will have no value.
Content Content
: The content of the resource itself. For most resources, this returns a string with the contents of the file. This can be used to inline some resources, such as `<script>{{ (.Resources.GetMatch "myscript.js").Content | safeJS }}</script>` or `<img src="{{ (.Resources.GetMatch "mylogo.png").Content | base64Encode }}">`. : The content of the resource itself. For most resources, this returns a string
with the contents of the file. Use this to create inline resources.
```go-html-template
{{ with .Resources.GetMatch "script.js" }}
<script>{{ .Content | safeJS }}</script>
{{ end }}
{{ with .Resources.GetMatch "style.css" }}
<style>{{ .Content | safeCSS }}</style>
{{ end }}
{{ with .Resources.GetMatch "img.png" }}
<img src="data:{{ .MediaType }};base64,{{ .Content | base64Encode }}">
{{ end }}
```
MediaType MediaType
: The MIME type of the resource, such as `image/jpeg`. : The MIME type of the resource, such as `image/jpeg`.

View file

@ -154,7 +154,7 @@ go install
Hugo relies on [mage](https://github.com/magefile/mage) for some convenient build and test targets. If you don't already have it, get it: Hugo relies on [mage](https://github.com/magefile/mage) for some convenient build and test targets. If you don't already have it, get it:
``` ```
go get github.com/magefile/mage go install github.com/magefile/mage@latest
``` ```
### Fork the repository ### Fork the repository

View file

@ -20,7 +20,7 @@ aliases: []
`.GetPage` returns a page of a given `path`. Both `Site` and `Page` implements this method. The `Page` variant will, if given a relative path -- i.e. a path without a leading `/` -- try look for the page relative to the current page. `.GetPage` returns a page of a given `path`. Both `Site` and `Page` implements this method. The `Page` variant will, if given a relative path -- i.e. a path without a leading `/` -- try look for the page relative to the current page.
{{% note %}} {{% note %}}
**Note:** We overhauled and simplified the `.GetPage` API in Hugo 0.45. Before that you needed to provide a `Kind` attribute in addition to the path, e.g. `{{ .Site.GetPage "section" "blog" }}`. This will still work, but is now superflous. **Note:** We overhauled and simplified the `.GetPage` API in Hugo 0.45. Before that you needed to provide a `Kind` attribute in addition to the path, e.g. `{{ .Site.GetPage "section" "blog" }}`. This will still work, but is now superfluous.
{{% /note %}} {{% /note %}}
@ -28,7 +28,7 @@ aliases: []
{{ with .Site.GetPage "/blog" }}{{ .Title }}{{ end }} {{ with .Site.GetPage "/blog" }}{{ .Title }}{{ end }}
``` ```
This method wil return `nil` when no page could be found, so the above will not print anything if the blog section is not found. This method will return `nil` when no page could be found, so the above will not print anything if the blog section is not found.
To find a regular page in the blog section:: To find a regular page in the blog section::

View file

@ -19,7 +19,7 @@ aliases: []
`dict` is especially useful for passing more than one value to a partial template. `dict` is especially useful for passing more than one value to a partial template.
Note that the `key` can be either a `string` or a `string slice`. The latter is useful to create a deply nested structure, e.g.: Note that the `key` can be either a `string` or a `string slice`. The latter is useful to create a deeply nested structure, e.g.:
```go-text-template ```go-text-template
{{ $m := dict (slice "a" "b" "c") "value" }} {{ $m := dict (slice "a" "b" "c") "value" }}

View file

@ -2,27 +2,41 @@
title: "fileExists" title: "fileExists"
linktitle: "fileExists" linktitle: "fileExists"
date: 2017-08-31T22:38:22+02:00 date: 2017-08-31T22:38:22+02:00
description: Checks whether a file exists under the given path. description: Checks for file or directory existence.
publishdate: 2017-08-31T22:38:22+02:00 publishdate: 2017-08-31T22:38:22+02:00
lastmod: 2017-08-31T22:38:22+02:00 lastmod: 2021-11-26
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
parent: "functions" parent: "functions"
signature: ["fileExists PATH"] signature: ["os.FileExists PATH","fileExists PATH"]
workson: [] workson: []
hugoversion: hugoversion:
relatedfuncs: [] relatedfuncs: ['os.ReadDir','os.ReadFile','os.Stat']
deprecated: false deprecated: false
aliases: [] aliases: []
--- ---
The `os.FileExists` function attempts to resolve the path relative to the root of your project directory. If a matching file or directory is not found, it will attempt to resolve the path relative to the [`contentDir`]({{< relref "getting-started/configuration#contentdir">}}). A leading path separator (`/`) is optional.
`fileExists` allows you to check if a file exists under a given path, e.g. before inserting code into a template: With this directory structure:
``` ```text
{{ if (fileExists "static/img/banner.jpg") -}} content/
<img src="{{ "img/banner.jpg" | absURL }}" /> ├── about.md
{{- end }} ├── contact.md
└── news/
├── article-1.md
└── article-2.md
``` ```
In the example above, a banner from the `static` folder should be shown if the given path points to an existing file. The function returns these values:
```go-html-template
{{ os.FileExists "content" }} --> true
{{ os.FileExists "content/news" }} --> true
{{ os.FileExists "content/news/article-1" }} --> false
{{ os.FileExists "content/news/article-1.md" }} --> true
{{ os.FileExists "news" }} --> true
{{ os.FileExists "news/article-1" }} --> false
{{ os.FileExists "news/article-1.md" }} --> true
```

View file

@ -1,30 +1,43 @@
--- ---
title: getenv title: getenv
description: Returns the value of an environment variable. description: Returns the value of an environment variable, or an empty string if the environment variable is not set.
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-01 lastmod: 2021-11-26
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
parent: "functions" parent: "functions"
keywords: [] keywords: []
signature: ["getenv VARIABLE"] signature: ["os.Getenv VARIABLE", "getenv VARIABLE"]
workson: [] workson: []
hugoversion: hugoversion:
relatedfuncs: [] relatedfuncs: []
deprecated: false deprecated: false
aliases: [] aliases: []
--- ---
Examples:
Takes a string containing the name of the variable as input. Returns ```go-html-template
an empty string if the variable is not set, otherwise returns the {{ os.Getenv "HOME" }} --> /home/victor
value of the variable. {{ os.Getenv "USER" }} --> victor
```
{{ getenv "HOME" }}
``` ```
{{% note %}} You can pass values when building your site:
In Unix-like environments, the variable must also be exported in order to be seen by `hugo`.
{{% /note %}} ```bash
MY_VAR1=foo MY_VAR2=bar hugo
OR
export MY_VAR1=foo
export MY_VAR2=bar
hugo
```
And then retrieve the values within a template:
```go-html-template
{{ os.Getenv "MY_VAR1" }} --> foo
{{ os.Getenv "MY_VAR2" }} --> bar
```

View file

@ -1,9 +1,9 @@
--- ---
title: os.Stat title: os.Stat
description: Gets a file information of a given path. description: Returns a FileInfo structure describing a file or directory.
date: 2018-08-07 date: 2018-08-07
publishdate: 2018-08-07 publishdate: 2018-08-07
lastmod: 2018-08-07 lastmod: 2021-11-26
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
@ -12,21 +12,21 @@ keywords: [files]
signature: ["os.Stat PATH"] signature: ["os.Stat PATH"]
workson: [] workson: []
hugoversion: hugoversion:
relatedfuncs: [readDir] relatedfuncs: ['os.FileExists','os.ReadDir','os.ReadFile']
deprecated: false deprecated: false
aliases: [] aliases: []
--- ---
The `os.Stat` function attempts to resolve the path relative to the root of your project directory. If a matching file or directory is not found, it will attempt to resolve the path relative to the [`contentDir`]({{< relref "getting-started/configuration#contentdir">}}). A leading path separator (`/`) is optional.
If your current project working directory has a single file named `README.txt` (30 bytes): ```go-html-template
``` {{ $f := os.Stat "README.md" }}
{{ $stat := os.Stat "README.txt" }} {{ $f.IsDir }} --> false (bool)
{{ $stat.Name }} → "README.txt" {{ $f.ModTime }} --> 2021-11-25 10:06:49.315429236 -0800 PST (time.Time)
{{ $stat.Size }} → 30 {{ $f.Name }} --> README.md (string)
{{ $f.Size }} --> 241 (int64)
{{ $d := os.Stat "content" }}
{{ $d.IsDir }} --> true (bool)
``` ```
Function [`os.Stat`][Stat] returns [`os.FileInfo`][osfileinfo]. Details of the `FileInfo` structure are available in the [Go documentation](https://pkg.go.dev/io/fs#FileInfo).
For further information of `os.FileInfo`, see [golang page][osfileinfo].
[Stat]: /functions/os.Stat/
[osfileinfo]: https://golang.org/pkg/os/#FileInfo

View file

@ -1,28 +1,51 @@
--- ---
title: readDir title: readDir
description: Gets a directory listing from a directory relative to the current working directory. description: Returns an array of FileInfo structures sorted by filename, one element for each directory entry.
date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-02-01 lastmod: 2021-11-26
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
parent: "functions" parent: "functions"
keywords: [files] keywords: [files]
signature: ["readDir PATH"] signature: ["os.ReadDir PATH", "readDir PATH"]
workson: [] workson: []
hugoversion: hugoversion:
relatedfuncs: [readFile] relatedfuncs: ['os.FileExists','os.ReadFile','os.Stat']
deprecated: false deprecated: false
aliases: [] aliases: []
--- ---
The `os.ReadDir` function resolves the path relative to the root of your project directory. A leading path separator (`/`) is optional.
If your current project working directory has a single file named `README.txt`: With this directory structure:
``` ```text
{{ range (readDir ".") }}{{ .Name }}{{ end }} → "README.txt" content/
├── about.md
├── contact.md
└── news/
├── article-1.md
└── article-2.md
``` ```
For more information on using `readDir` and `readFile` in your templates, see [Local File Templates][local]. This template code:
[local]: /templates/files/ ```go-html-template
{{ range os.ReadDir "content" }}
{{ .Name }} --> {{ .IsDir }}
{{ end }}
```
Produces:
```html
about.md --> false
contact.md --> false
news --> true
```
Note that `os.ReadDir` is not recursive.
Details of the `FileInfo` structure are available in the [Go documentation](https://pkg.go.dev/io/fs#FileInfo).
For more information on using `readDir` and `readFile` in your templates, see [Local File Templates]({{< relref "/templates/files" >}}).

View file

@ -1,32 +1,41 @@
--- ---
title: readFile title: readFile
description: Reads a file from disk relative to the current project working directory and returns a string. description: Returns the contents of a file.
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01 publishdate: 2017-02-01
lastmod: 2017-04-30 lastmod: 2021-11-26
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
parent: "functions" parent: "functions"
keywords: [files] keywords: [files]
signature: ["readFile PATH"] signature: ["os.ReadFile PATH", "readFile PATH"]
workson: [] workson: []
hugoversion: hugoversion:
relatedfuncs: [readDir] relatedfuncs: ['os.FileExists','os.ReadDir','os.Stat']
deprecated: false deprecated: false
aliases: [] aliases: []
--- ---
The `os.ReadFile` function attempts to resolve the path relative to the root of your project directory. If a matching file is not found, it will attempt to resolve the path relative to the [`contentDir`]({{< relref "getting-started/configuration#contentdir">}}). A leading path separator (`/`) is optional.
Note that the filename must be relative to the current project working directory, or the project's `/content` folder. With a file named README.md in the root of your project directory:
So, if you have a file with the name `README.txt` in the root of your project with the content `Hugo Rocks!`: ```text
This is **bold** text.
```
{{readFile "README.txt"}} → "Hugo Rocks!"
``` ```
If you receive a "file doesn't exist" error with a path listed, do take note that the path is the last one checked by the function, and may not accurately reflect your target. You should generally double-check your path for mistakes. This template code:
For more information on using `readDir` and `readFile` in your templates, see [Local File Templates][local]. ```go-html-template
{{ os.ReadFile "README.md" }}
```
[local]: /templates/files/ Produces:
```html
This is **bold** text.
```
Note that `os.ReadFile` returns raw (uninterpreted) content.
For more information on using `readDir` and `readFile` in your templates, see [Local File Templates]({{< relref "/templates/files" >}}).

View file

@ -22,7 +22,7 @@ It normally takes two parameters: `start` and `length`. It can also take one par
To extract characters from the end of the string, use a negative start number. To extract characters from the end of the string, use a negative start number.
In addition, borrowing from the extended behavior described at https://php.net substr, if `length` is given and is negative, that number of characters will be omitted from the end of string. If `length` is given and is negative, that number of characters will be omitted from the end of string.
``` ```
{{ substr "abcdef" 0 }} → "abcdef" {{ substr "abcdef" 0 }} → "abcdef"

View file

@ -1,35 +1,31 @@
--- ---
title: .Unix title: .Unix
draft: false description: Converts a time.Time value to the number of seconds elapsed since the Unix epoch, excluding leap seconds. The Unix epoch is 00:00:00&nbsp;UTC on 1 January 1970.
description: .Unix returns the local Time corresponding to the given Unix time, sec seconds and nsec nanoseconds since January 1, 1970 UTC.
date: 2017-02-01 date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
keywords: [dates,time] keywords: [dates,time]
categories: [functions] categories: [functions]
menu: menu:
docs: docs:
parent: "functions" parent: "functions"
signature: [".Unix"] signature: [".Unix",".UnixMilli",".UnixMicro",".UnixNano"]
workson: [times]
hugoversion:
relatedfuncs: [Format,dateFormat,now,time] relatedfuncs: [Format,dateFormat,now,time]
deprecated: false
aliases: []
--- ---
## Example: Time Passed Since Last Modification The `Milli`, `Micro`, and `Nano` variants return the number of milliseconds, microseconds, and nanoseconds (respectively) elapsed since the Unix epoch.
This very simple one-liner uses `now.Unix` to calculate the amount of time that has passed between the `.LastMod` for the current page and the last build of the current page. ```go-html-template
.Date.Unix --> 1637259694
.ExpiryDate.Unix --> 1672559999
.Lastmod.Unix --> 1637361786
.PublishDate.Unix --> 1637421261
{{< code file="time-passed.html" >}} ("1970-01-01T00:00:00-00:00" | time.AsTime).Unix --> 0
{{ div (sub now.Unix .Lastmod.Unix) 86400 }} ("1970-01-01T00:00:42-00:00" | time.AsTime).Unix --> 42
{{< /code >}} ("1970-04-11T01:48:29-08:00" | time.AsTime).Unix --> 8675309
("2026-05-02T20:09:31-07:00" | time.AsTime).Unix --> 1777777771
Since both values are integers, they can be subtracted and then divided by the number of seconds in a day (i.e., `60 * 60 * 24 == 86400`). now.Unix --> 1637447841
now.UnixMilli --> 1637447841347
{{% note %}} now.UnixMicro --> 1637447841347378
Hugo's output is *static*. For the example above to be realistic, the site needs to be built every day. now.UnixNano --> 1637447841347378799
{{% /note %}} ```
[partial template]: /templates/partials/

View file

@ -1,79 +0,0 @@
---
title: Code Toggle
description: Code Toggle tryout and showcase.
date: 2018-03-16
categories: [getting started,fundamentals]
keywords: [configuration,toml,yaml,json]
weight: 60
sections_weight: 60
draft: false
toc: true
---
## The Config Toggler!
This is an example 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.
{{% note %}}
The `code-toggler` shortcode is not an internal Hugo shortcode. This page's purpose is to test out a custom feature that we use throughout this site. See: https://github.com/gohugoio/gohugoioTheme/blob/master/layouts/shortcodes/code-toggle.html
{{% /note %}}
## That Config Toggler
{{< code-toggle file="config">}}
baseURL: "https://yoursite.example.com/"
title: "My Hugo Site"
footnoteReturnLinkContents: "↩"
permalinks:
posts: /:year/:month/:title/
params:
Subtitle: "Hugo is Absurdly Fast!"
AuthorName: "Jon Doe"
GitHubUser: "spf13"
ListOfFoo:
- "foo1"
- "foo2"
SidebarRecentLimit: 5
{{< /code-toggle >}}
## Another Config Toggler!
{{< code-toggle file="theme">}}
# theme.toml template for a Hugo theme
name = "Hugo Theme"
license = "MIT"
licenselink = "https://github.com/budparr/gohugo.io/blob/master/LICENSE.md"
description = ""
homepage = "https://github.com/budparr/gohugo.io"
tags = ["website"]
features = ["", ""]
min_version = 0.18
[author]
name = "Bud Parr"
homepage = "https://github.com/budparr"
{{< /code-toggle >}}
## Two regular code blocks
{{< code file="bf-config.toml" >}}
[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 >}}

View file

@ -166,6 +166,12 @@ Enable to turn relative URLs into absolute.
The directory from where Hugo reads content files. {{% module-mounts-note %}} The directory from where Hugo reads content files. {{% module-mounts-note %}}
### copyright
**Default value:** ""
Copyright notice for your site, typically displayed in the footer.
### dataDir ### dataDir
**Default value:** "data" **Default value:** "data"
@ -275,6 +281,12 @@ If true, auto-detect Chinese/Japanese/Korean Languages in the content. This will
### imaging ### imaging
See [Image Processing Config](/content-management/image-processing/#image-processing-config). See [Image Processing Config](/content-management/image-processing/#image-processing-config).
### languageCode
**Default value:** ""
A language tag as defined by [RFC 5646](https://datatracker.ietf.org/doc/html/rfc5646). The internal [RSS template](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml) populates its `<language>` element with this value. The value is not used elsewhere.
### languages ### languages
See [Configure Languages](/content-management/multilingual/#configure-languages). See [Configure Languages](/content-management/multilingual/#configure-languages).
@ -351,6 +363,17 @@ When using `ref` or `relref` to resolve page links and a link cannot resolved, i
### refLinksNotFoundURL ### refLinksNotFoundURL
URL to be used as a placeholder when a page reference cannot be found in `ref` or `relref`. Is used as-is. URL to be used as a placeholder when a page reference cannot be found in `ref` or `relref`. Is used as-is.
### removePathAccents
**Default value:** false
Removes [non-spacing marks](https://www.compart.com/en/unicode/category/Mn) from [composite characters](https://en.wikipedia.org/wiki/Precomposed_character) in content paths.
```text
content/post/hügó.md --> https://example.org/post/hugo/
```
### rssLimit ### rssLimit
Maximum number of items in the RSS feed. Maximum number of items in the RSS feed.
@ -381,9 +404,9 @@ The directory where Hugo reads the themes from.
### timeout ### timeout
**Default value:** 10000 **Default value:** "30s"
Timeout for generating page contents, in milliseconds (defaults to 10&nbsp;seconds). *Note:* this is used to bail out of recursive content generation, if your pages are slow to generate (e.g., because they require large image processing or depend on remote contents) you might need to raise this limit. Timeout for generating page contents, specified as a [duration](https://pkg.go.dev/time#Duration) or in milliseconds. *Note:*&nbsp;this is used to bail out of recursive content generation. You might need to raise this limit if your pages are slow to generate (e.g., because they require large image processing or depend on remote contents).
### timeZone ### timeZone
@ -456,7 +479,7 @@ This is only relevant when running `hugo server`, and it allows to set HTTP head
{{< code-toggle file="config">}} {{< code-toggle file="config">}}
[server] [server]
[[server.headers]] [[server.headers]]
for = "/**.html" for = "/**"
[server.headers.values] [server.headers.values]
X-Frame-Options = "DENY" X-Frame-Options = "DENY"
@ -471,7 +494,7 @@ Since this is is "development only", it may make sense to put it below the `deve
{{< code-toggle file="config/development/server">}} {{< code-toggle file="config/development/server">}}
[[headers]] [[headers]]
for = "/**.html" for = "/**"
[headers.values] [headers.values]
X-Frame-Options = "DENY" X-Frame-Options = "DENY"
@ -564,12 +587,18 @@ Test and document setting params via JSON env var.
## Ignore Content and Data Files when Rendering ## Ignore Content and Data Files when Rendering
To exclude specific files from the content and data directories when rendering your site, set `ignoreFiles` to one or more regular expressions. To exclude specific files from the `content` and `data` directories when rendering your site, set `ignoreFiles` to one or more regular expressions to match against the absolute file path.
For example, to ignore content and data files ending with `.foo` and `.boo`: To ignore files ending with `.foo` or `.boo`:
{{< code-toggle >}} {{< code-toggle copy="false" >}}
ignoreFiles = [ "\\.foo$","\\.boo$"] ignoreFiles = ['\.foo$', '\.boo$']
{{< /code-toggle >}}
To ignore a file using the absolute file path:
{{< code-toggle copy="false" >}}
ignoreFiles = ['^/home/user/project/content/test\.md$']
{{< /code-toggle >}} {{< /code-toggle >}}
## Configure Front Matter ## Configure Front Matter

View file

@ -516,6 +516,14 @@ For the latest version, the Hugo package maintained by [@daftaupe](https://githu
See the [related discussion in the Hugo forums][redhatforum]. See the [related discussion in the Hugo forums][redhatforum].
### openSUSE Tumbleweed
openSUSE maintains an [official package](https://software.opensuse.org/package/hugo) for the Tumbleweed rolling release distribution, it may be installed with:
````
sudo zypper install hugo
````
### Solus ### Solus
Solus includes Hugo in its package repository, it may be installed with: Solus includes Hugo in its package repository, it may be installed with:

View file

@ -86,6 +86,14 @@ jobs:
For more advanced settings [actions-hugo](https://github.com/marketplace/actions/hugo-setup) and [actions-gh-pages](https://github.com/marketplace/actions/github-pages-action). For more advanced settings [actions-hugo](https://github.com/marketplace/actions/hugo-setup) and [actions-gh-pages](https://github.com/marketplace/actions/github-pages-action).
## Github pages setting
By default, the GitHub action pushes the generated content to the `gh-pages` branch. This means GitHub has to serve your `gh-pages` branch as a GitHub Pages branch. You can change this setting by going to Settings > GitHub Pages, and change the source branch to `gh-pages`.
## Change baseURL in config.toml
Don't forget to rename your `baseURL` in `config.toml` with the value `https://<USERNAME>.github.io` for your user repository or `https://<USERNAME>.github.io/<REPOSITORY_NAME>` for a project repository.
Unless this is present in your `config.toml`, your website won't work.
## Use a Custom Domain ## Use a Custom Domain
If you'd like to use a custom domain for your GitHub Pages site, create a file `static/CNAME`. Your custom domain name should be the only contents inside `CNAME`. Since it's inside `static`, the published site will contain the CNAME file at the root of the published site, which is a requirement of GitHub Pages. If you'd like to use a custom domain for your GitHub Pages site, create a file `static/CNAME`. Your custom domain name should be the only contents inside `CNAME`. Since it's inside `static`, the published site will contain the CNAME file at the root of the published site, which is a requirement of GitHub Pages.

View file

@ -6,7 +6,7 @@ date: 2019-06-06
publishdate: 2019-06-06 publishdate: 2019-06-06
lastmod: 2020-01-01 lastmod: 2020-01-01
categories: [hosting and deployment] categories: [hosting and deployment]
keywords: [render,hosting,deployment] keywords: [hosting,deployment]
authors: [Anurag Goel] authors: [Anurag Goel]
menu: menu:
docs: docs:

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

View file

@ -1,13 +1,12 @@
--- ---
date: 2021-11-02 date: 2021-11-02
title: "0.89.0" title: "Fine Grained File Filters"
description: "0.89.0" description: "Hugo 0.89.0 brings fine grained file filters, archetype rewrite, dependency refresh, and more ..."
categories: ["Releases"] categories: ["Releases"]
--- ---
This release is a dependency refresh (the new Goldmark version comes with a lot of bug fixes, as one example), many bug fixes, but also some nice new features:
This release is a dependency refresh (the new Goldmark verion comes with a lot of bug fixes, as one example), many bug fixes, but also some nice new features:
We have added the [configuration settings](https://gohugo.io/hugo-modules/configuration/#module-config-mounts) **includeFiles** and **excludeFiles** to the mount configuration. This allows fine grained control over what files to include, and it works for all of Hugo's file systems (including `/static`). We have added the [configuration settings](https://gohugo.io/hugo-modules/configuration/#module-config-mounts) **includeFiles** and **excludeFiles** to the mount configuration. This allows fine grained control over what files to include, and it works for all of Hugo's file systems (including `/static`).
@ -17,7 +16,7 @@ We have also [reimplemented archetypes](https://github.com/gohugoio/hugo/pull/90
hugo new content/en/posts/my-first-post.md hugo new content/en/posts/my-first-post.md
``` ```
This release represents **50 contributions by 13 contributors** to the main Hugo code base.[@bep](https://github.com/bep) leads the Hugo development with a significant amount of contributions, but also a big shoutout to [@dependabot[bot]](https://github.com/apps/dependabot), [@jmooring](https://github.com/jmooring), and [@anthonyfok](https://github.com/anthonyfok) for their ongoing contributions. This release represents **50 contributions by 13 contributors** to the main Hugo code base. [@bep](https://github.com/bep) leads the Hugo development with a significant amount of contributions, but also a big shoutout to [@dependabot[bot]](https://github.com/apps/dependabot), [@jmooring](https://github.com/jmooring), and [@anthonyfok](https://github.com/anthonyfok) for their ongoing contributions.
And thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) for his ongoing work on keeping the themes site in pristine condition. And thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) for his ongoing work on keeping the themes site in pristine condition.
Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs), Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs),
@ -35,10 +34,10 @@ Hugo now has:
* Hugo now writes an empty file named `.hugo_build.lock` to the root of the project when building (also when doing `hugo new mypost.md` and other commands that requires a build). We recommend you just leave this file alone. Put it in `.gitignore` or similar if you don't want the file in your source repository. * Hugo now writes an empty file named `.hugo_build.lock` to the root of the project when building (also when doing `hugo new mypost.md` and other commands that requires a build). We recommend you just leave this file alone. Put it in `.gitignore` or similar if you don't want the file in your source repository.
* We have updated to ESBuild `v0.13.12`. The release notes for [v0.13.0](https://github.com/evanw/esbuild/releases/tag/v0.13.0) mentions a potential breaking change. * We have updated to ESBuild `v0.13.12`. The release notes for [v0.13.0](https://github.com/evanw/esbuild/releases/tag/v0.13.0) mentions a potential breaking change.
* We now only build AMD64 release binaries (see [this issue](https://github.com/gohugoio/hugo/issues/9102)) for the Unix OSes (e.g. NetBSD). If need, say, a binary for ARM64, you need to build it yourself. * We now only build AMD64 release binaries (see [this issue](https://github.com/gohugoio/hugo/issues/9102)) for the Unix OSes (e.g. NetBSD). If you need, say, a binary for ARM64, you need to build it yourself.
* We now build only one release binary/archive for MacOS, see [this issue](https://github.com/gohugoio/hugo/issues/9035) that works on both Intel and the new Arm M1 systems. * We now build only one release binary/archive for MacOS (see [this issue](https://github.com/gohugoio/hugo/issues/9035)) that works on both Intel and the new Arm M1 systems.
* `.File.ContentBaseName` now returns the owning directory name for all bundles (branch an leaf). This is a bug fix, but worth mentioning. See [this issue](https://github.com/gohugoio/hugo/issues/9112). * `.File.ContentBaseName` now returns the owning directory name for all bundles (branch an leaf). This is a bug fix, but worth mentioning. See [this issue](https://github.com/gohugoio/hugo/issues/9112).
* We have updated the Twitter shortcode to use Twitter's new API. See [thiss issue] for details. * We have updated the Twitter shortcode to use Twitter's new API. See [this issue](https://github.com/gohugoio/hugo/pull/9106) for details.
## Enhancements ## Enhancements
@ -105,8 +104,3 @@ Hugo now has:
* Fix the "page picker" logic in --navigateToChanged [096f5e19](https://github.com/gohugoio/hugo/commit/096f5e19217e985bccbf6c539e1b220541ffa6f6) [@bep](https://github.com/bep) [#9051](https://github.com/gohugoio/hugo/issues/9051) * Fix the "page picker" logic in --navigateToChanged [096f5e19](https://github.com/gohugoio/hugo/commit/096f5e19217e985bccbf6c539e1b220541ffa6f6) [@bep](https://github.com/bep) [#9051](https://github.com/gohugoio/hugo/issues/9051)
* Fix a typo on OpenBSD [c7957c90](https://github.com/gohugoio/hugo/commit/c7957c90e83ff2b2cc958bd61486a244f0fd8891) [@nabbisen](https://github.com/nabbisen) * Fix a typo on OpenBSD [c7957c90](https://github.com/gohugoio/hugo/commit/c7957c90e83ff2b2cc958bd61486a244f0fd8891) [@nabbisen](https://github.com/nabbisen)
* Fix value of useResourceCacheWhen in TestResourceChainPostCSS [e6e44b7c](https://github.com/gohugoio/hugo/commit/e6e44b7c41a9b517ffc3775ea0a6aec2b1d4591b) [@jmooring](https://github.com/jmooring) * Fix value of useResourceCacheWhen in TestResourceChainPostCSS [e6e44b7c](https://github.com/gohugoio/hugo/commit/e6e44b7c41a9b517ffc3775ea0a6aec2b1d4591b) [@jmooring](https://github.com/jmooring)

View file

@ -1,8 +1,8 @@
--- ---
date: 2021-11-17 date: 2021-11-17
title: "Hugo 0.89.4: A couple of Bug Fixes" title: "Hugo 0.89.4: One Bug Fix"
description: "This version fixes a couple of bugs introduced in 0.89.0." description: "This version fixes one bug introduced in 0.89.0."
categories: ["Releases"] categories: ["Releases"]
images: images:
- images/blog/hugo-bug-poster.png - images/blog/hugo-bug-poster.png
@ -11,7 +11,7 @@ images:
This is a bug-fix release with one important fix. This is a bug-fix release with one important fix for people using `hugo new` to create new content:
* Fix content dir resolution when main project is a Hugo Module [2e70f61f](https://github.com/gohugoio/hugo/commit/2e70f61fb04cea08ef6598728a57637ae2cc199c) [@bep](https://github.com/bep) [#9177](https://github.com/gohugoio/hugo/issues/9177) * Fix content dir resolution when main project is a Hugo Module [2e70f61f](https://github.com/gohugoio/hugo/commit/2e70f61fb04cea08ef6598728a57637ae2cc199c) [@bep](https://github.com/bep) [#9177](https://github.com/gohugoio/hugo/issues/9177)

View file

@ -1,9 +0,0 @@
[**Aether**](https://getaether.net) is an open-source peer-to-peer network that hosts self-moderating online-communities.
[**Aether Pro**](https://aether.app), based on Aether, is a collaboration tool for remote-friendly companies.
The site is built by:
* [Burak Nehbit](https://twitter.com/nehbit)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 KiB

View file

@ -1,39 +0,0 @@
---
title: Aether
date: 2020-02-26
description: "Showcase: \"Hugo is not just a static site generator for us, it's the core framework at the heart of our entire web front-end.\""
# The URL to the site on the internet.
siteURL: https://getaether.net
# Add credit to the article author. Leave blank or remove if not needed/wanted.
byline: "[Burak Nehbit](https://twitter.com/nehbit), Maintainer, Aether"
---
To say that this website, our main online presence, needed to do a lot would be an understatement.
Our site is home to both *Aether* and *Aether Pro*, our **knowledgebase for each product**, a **server for static assets that we use in our emails**, the **interactive sign-up flows**, **payments client**, **downloads provider**, and even a **mechanism for delivering auto-update notifications** to our native clients. We are using a single Hugo site for all these — it's not a static site generator for us, it's the core framework at the heart of our *entire* web front-end.
Not only that, this had to work with one developer crunched for time who spends most of his time working on two separate apps across 3 desktop platforms — someone whose main job is very far from building static websites. We only had scraps of time to design and build this Hugo site, make it performant and scalable, and Hugo did a phenomenal job delivering on that promise.
The last piece is, funnily enough, moving our blog to Hugo, which it is not as of now. This was an inherited mistake we are currently rectifying. Soon, our entire web footprint will be living in Hugo.
### Structure
Our website is built in such a way that there is a separate Vue.js instance for each of the contexts since we are not using JS-based single-page navigation. We use Hugo for navigation and to build most pages. For the pages we need to make interactive, we use Vue.js to build individual, self-contained single-page Javascript apps. One such example is our sign-up flow at [aether.app](https://aether.app), an individual Vue app living within a Hugo page, with its own JS-based navigation.
This is a relatively complex setup, and somewhat out of the ordinary. Yet, even with this custom setup, using Hugo was painless.
### Tools
**CMS**: Hugo
**Theme**: Custom-designed
**Hosting**: Netlify, pushed to production via `git push`.
**Javascript runtime**: Vue.js

View file

@ -1,6 +0,0 @@
[Camping Arolla](https://www.camping-arolla.com) is located in the heart of the Swiss Alps, at an altitude of 1.950 meters.
The site is built by:
* [Didier Divinerites](https://github.com/divinerites)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 441 KiB

View file

@ -1,29 +0,0 @@
---
title: Cocoon & Cosy
date: 2018-08-10
description: "Showcase: \"Emergency setup a dedicated site in an afternoon.\""
siteURL: https://www.cocoon-arolla.com
byline: "[Didier Divinerites](https://github.com/divinerites)"
---
Swiss [Arolla campsite](https://www.camping-arolla.com) runs the highest campsite in Europe and I'm completely re-doing their actual Website with Hugo.
But they just launch a brand new offer (luxury tents with bed and fire oven), and we couldn't wait for the proper new website for having this promoted: we needed the website up and running within 24h!
So we decided to quickly launch a dedicated [independent web site](https://www.cocoon-arolla.com) using all the powerful tools included with [gohugo.io](https://gohugo.io) and some things we already knew & used:
- Choose a spectacular landing theme in the rich [Hugo Themes](https://themes.gohugo.io/) collection : [Airspace Theme](https://themes.gohugo.io/airspace-hugo/) by Themefisher.
- Replace the main images.
- Add a [hugo-easy-gallery / photoswipe](https://github.com/liwenyip/hugo-easy-gallery) on the main page with attractive images.
- Add the promo video with a simple *vimeo* shortcode.
- Replace the Google Maps widget by the [OpenStreetMap](https://www.openstreetmap.org/) equivalent
- Use a [Zotabox](https://www.zotabox.com) contact form.
- Write the content in French & in English directly on the content pages, describe their services, add fun facts and true testimonies.
- Setup a GDPR compliant site with the new Hugo options.
- Use [Netlify](https://www.netlify.com) for publishing it in a breeze.
The first version was up in 4 hours, and the polished 2 languages version was published on Netlify the next day.
This would have been impossible to do it in such a short time without all the powerful Hugo tools and Netlify simplicity.

View file

@ -1,4 +0,0 @@
Pace was started in 2016 to give hotels the super-power to always have the right price.
We've been using **Hugo+Gulp** from the very beginning and the workflow is proving to scale incredibly well with us as we grow the team and business.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 KiB

View file

@ -1,28 +0,0 @@
---
title: Pace Revenue Management
date: 2018-02-08
description: "Showcase: \"When we came across Hugo we were blown away.\""
siteURL: https://www.paceup.com/
# Link to the site's Hugo source code if public and you can/want to share.
# Remove or leave blank if not needed/wanted.
# Add credit to the article author. Leave blank or remove if not needed/wanted.
---
From the beginning, at Pace, we were focused on solving customer needs and didn't want to over-engineer our marketing or sales. At the same time we didn't want to lock ourselves into a WordPress, Squarespace or the like.
The ideal was a fast, simple, static site builder. When we came across Hugo we were blown away. Being a European company we wanted to be multi-lingual from the get-go and allow multiple team-members to collaborate and own their content. We also felt that a tech-company in 2018 should be capable of hosting its own blog in a simple way.
Here was Hugo, that allowed us to completely separate content from layout. Our sales-team edit a markdown-file, the engineers commit and off we go -- immediately deployable or pre-viewable.
The only other way to have all that Hugo offers is to go down the full rabbit-hole of building your own server-side React or some such. Possibly Jekyll but again very complex to work with. The alternatives come with too much work for what should be quite simple.
**Hugo + Gulp + Netlify for the win! Don't over engineer your web presence!**
Huge thanks to [@bep](https://github.com/bep) and [community](https://discourse.gohugo.io/) for Hugo.

View file

@ -69,7 +69,7 @@ Hugo also ships with an internal template for [Disqus comments][disqus], a popul
To use Hugo's Disqus template, you first need to set a single configuration value: To use Hugo's Disqus template, you first need to set a single configuration value:
{{< code-toggle file="config" >}} {{< code-toggle file="config" >}}
disqusShortname = "yourdiscussshortname" disqusShortname = "your-disqus-shortname"
{{</ code-toggle >}} {{</ code-toggle >}}
You also have the option to set the following in the front matter for a given piece of content: You also have the option to set the following in the front matter for a given piece of content:
@ -209,7 +209,6 @@ To add Twitter card metadata, include the following line between the `<head>` ta
## The Internal Templates ## The Internal Templates
* `_internal/disqus.html` * `_internal/disqus.html`
* `_internal/google_news.html`
* `_internal/google_analytics.html` * `_internal/google_analytics.html`
* `_internal/google_analytics_async.html` * `_internal/google_analytics_async.html`
* `_internal/opengraph.html` * `_internal/opengraph.html`

View file

@ -151,7 +151,7 @@ Go Templates only ship with a few basic functions but also provide a mechanism f
<!-- prints true (i.e., since 1 is less than 2) --> <!-- prints true (i.e., since 1 is less than 2) -->
``` ```
Note that both examples make use of Go Template's [math functions][]. Note that both examples make use of Go Template's [math]][] functions.
{{% note "Additional Boolean Operators" %}} {{% note "Additional Boolean Operators" %}}
There are more boolean operators than those listed in the Hugo docs in the [Go Template documentation](https://golang.org/pkg/text/template/#hdr-Functions). There are more boolean operators than those listed in the Hugo docs in the [Go Template documentation](https://golang.org/pkg/text/template/#hdr-Functions).
@ -184,7 +184,7 @@ Example of including a `layouts/partials/header.html` partial:
The `template` function was used to include *partial* templates The `template` function was used to include *partial* templates
in much older Hugo versions. Now it's useful only for calling in much older Hugo versions. Now it's useful only for calling
[*internal* templates][internal_templates]. The syntax is `{{ template [*internal* templates][internal templates]. The syntax is `{{ template
"_internal/<TEMPLATE>.<EXTENSION>" . }}`. "_internal/<TEMPLATE>.<EXTENSION>" . }}`.
{{% note %}} {{% note %}}
@ -630,48 +630,69 @@ Finally, you can pull "magic constants" out of your layouts as well. The followi
</nav> </nav>
``` ```
## Example: Show Only Upcoming Events ## Example: Show Future Events
Go allows you to do more than what's shown here. Using Hugo's [`where` function][where] and Go built-ins, we can list only the items from `content/events/` whose date (set in a content file's [front matter][]) is in the future. The following is an example [partial template][partials]: Given the following content structure and [front matter]:
{{< code file="layouts/partials/upcoming-events.html" download="upcoming-events.html" >}} ```text
<h4>Upcoming Events</h4> content/
<ul class="upcoming-events"> └── events/
{{ range where .Pages.ByDate "Section" "events" }} ├── event-1.md
{{ if ge .Date.Unix now.Unix }} ├── event-2.md
<li> └── event-3.md
<!-- add span for event type --> ```
<span>{{ .Type | title }} —</span>
{{ .Title }} on {{< code-toggle file="content/events/event-1.md" copy="false" >}}
<!-- add span for event date --> title = 'Event 1'
<span>{{ .Date.Format "2 January at 3:04pm" }}</span> date = 2021-12-06T10:37:16-08:00
at {{ .Params.place }} draft = false
</li> start_date = 2021-12-05T09:00:00-08:00
end_date = 2021-12-05T11:00:00-08:00
{{< /code-toggle >}}
This [partial template][partials] renders future events:
{{< code file="layouts/partials/future-events.html" >}}
<h2>Future Events</h2>
<ul>
{{ range where site.RegularPages "Type" "events" }}
{{ if gt (.Params.start_date | time.AsTime) now }}
{{ $startDate := .Params.start_date | time.Format ":date_medium" }}
<li>
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a> - {{ $startDate }}
</li>
{{ end }} {{ end }}
{{ end }} {{ end }}
</ul> </ul>
{{< /code >}} {{< /code >}}
If you restrict front matter to the TOML format, and omit quotation marks surrounding date fields, you can perform date comparisons without casting.
[`where` function]: /functions/where/ {{< code file="layouts/partials/future-events.html" >}}
[config]: /getting-started/configuration/ <h2>Future Events</h2>
<ul>
{{ range where (where site.RegularPages "Type" "events") "Params.start_date" "gt" now }}
{{ $startDate := .Params.start_date | time.Format ":date_medium" }}
<li>
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a> - {{ $startDate }}
</li>
{{ end }}
</ul>
{{< /code >}}
[config]: {{< relref "getting-started/configuration" >}}
[dotdoc]: https://golang.org/pkg/text/template/#hdr-Variables [dotdoc]: https://golang.org/pkg/text/template/#hdr-Variables
[first]: /functions/first/ [first]: {{< relref "functions/first" >}}
[front matter]: /content-management/front-matter/ [front matter]: {{< relref "content-management/front-matter" >}}
[functions]: /functions/ "See the full list of Hugo's templating functions with a quick start reference guide and basic and advanced examples." [functions]: {{< relref "functions" >}}
[Go html/template]: https://golang.org/pkg/html/template/ "Godocs references for Go's html templating" [internal templates]: {{< relref "templates/internal" >}}
[gohtmltemplate]: https://golang.org/pkg/html/template/ "Godocs references for Go's html templating" [isset]: {{< relref "functions/isset" >}}
[index]: /functions/index-function/ [math]: {{< relref "functions/math" >}}
[math functions]: /functions/math/ [pagevars]: {{< relref "variables/page" >}}
[partials]: /templates/partials/ "Link to the partial templates page inside of the templating section of the Hugo docs" [param]: {{< relref "functions/param" >}}
[internal_templates]: /templates/internal/ [partials]: {{< relref "templates/partials" >}}
[relpermalink]: /variables/page/ [relpermalink]: {{< relref "variables/page#page-variables" >}}
[safehtml]: /functions/safehtml/ [safehtml]: {{< relref "functions/safehtml" >}}
[sitevars]: /variables/site/ [sitevars]: {{< relref "variables/site" >}}
[pagevars]: /variables/page/ [variables]: {{< relref "variables" >}}
[variables]: /variables/ "See the full extent of page-, site-, and other variables that Hugo make available to you in your templates." [with]: {{< relref "functions/with" >}}
[where]: /functions/where/
[with]: /functions/with/
[godocsindex]: https://golang.org/pkg/text/template/ "Godocs page for index function"
[param]: /functions/param/
[isset]: /functions/isset/

View file

@ -72,7 +72,7 @@ All the methods below, e.g. `.Site.RegularPages` can also be reached via the glo
: indicates the language currently being used to render the website. This object's attributes are set in site configurations' language definition. : indicates the language currently being used to render the website. This object's attributes are set in site configurations' language definition.
.Site.LanguageCode .Site.LanguageCode
: a string representing the language as defined in the site configuration. This is mostly used to populate the RSS feeds with the right language code. : a string representing the language tag as defined in the site configuration.
.Site.LanguagePrefix .Site.LanguagePrefix
: this can be used to prefix URLs to point to the correct language. It will even work when only one defined language. See also the functions [absLangURL](/functions/abslangurl/) and [relLangURL](/functions/rellangurl). : this can be used to prefix URLs to point to the correct language. It will even work when only one defined language. See also the functions [absLangURL](/functions/abslangurl/) and [relLangURL](/functions/rellangurl).

View file

@ -29,7 +29,7 @@
<div class="tab-content"> <div class="tab-content">
{{ range $langs }} {{ range $langs }}
<div data-pane="{{ . }}" class="code-copy-content nt3 tab-pane {{ cond (eq . "yaml") "active" ""}}"> <div data-pane="{{ . }}" class="code-copy-content nt3 tab-pane {{ cond (eq . "yaml") "active" ""}}">
{{ highlight ($code | transform.Remarshal . | safeHTML) . ""}} {{ highlight ($code | transform.Remarshal . | replaceRE `\n+` "\n" | safeHTML) . "" }}
</div> </div>
{{ if ne ($.Get "copy") "false" }} {{ if ne ($.Get "copy") "false" }}
<button class="needs-js copy copy-toggle bg-accent-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2" title="Copy this code to your clipboard." data-clipboard-action="copy" aria-label="copy button"></button> <button class="needs-js copy copy-toggle bg-accent-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2" title="Copy this code to your clipboard." data-clipboard-action="copy" aria-label="copy button"></button>
@ -37,5 +37,5 @@
{{end}} {{end}}
{{ end }} {{ end }}
</div> </div>
</div> </div>

View file

@ -4,8 +4,9 @@
{{ range $k, $v := $funcs }} {{ range $k, $v := $funcs }}
{{ if $v.Description }} {{ if $v.Description }}
{{ $func := printf "%s.%s" $pkg $k }} {{ $func := printf "%s.%s" $pkg $k }}
<h2> {{ $id := $func | anchorize | safeURL }}
<a class="header-link" href="#{{ $func | anchorize | safeURL }}"> <h2 id="{{ $id }}">
<a class="header-link" href="#{{ $id }}">
<svg class="fill-current o-60 hover-accent-color-light" height="22px" viewBox="0 0 24 24" width="22px" xmlns="http://www.w3.org/2000/svg"> <svg class="fill-current o-60 hover-accent-color-light" height="22px" viewBox="0 0 24 24" width="22px" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0z" fill="none"/> <path d="M0 0h24v24H0z" fill="none"/>
<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/> <path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>

View file

@ -3,7 +3,7 @@ publish = "public"
command = "hugo --gc --minify" command = "hugo --gc --minify"
[context.production.environment] [context.production.environment]
HUGO_VERSION = "0.88.1" HUGO_VERSION = "0.89.4"
HUGO_ENV = "production" HUGO_ENV = "production"
HUGO_ENABLEGITINFO = "true" HUGO_ENABLEGITINFO = "true"
@ -11,20 +11,20 @@ HUGO_ENABLEGITINFO = "true"
command = "hugo --gc --minify --enableGitInfo" command = "hugo --gc --minify --enableGitInfo"
[context.split1.environment] [context.split1.environment]
HUGO_VERSION = "0.88.1" HUGO_VERSION = "0.89.4"
HUGO_ENV = "production" HUGO_ENV = "production"
[context.deploy-preview] [context.deploy-preview]
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL" command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
[context.deploy-preview.environment] [context.deploy-preview.environment]
HUGO_VERSION = "0.88.1" HUGO_VERSION = "0.89.4"
[context.branch-deploy] [context.branch-deploy]
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL" command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
[context.branch-deploy.environment] [context.branch-deploy.environment]
HUGO_VERSION = "0.88.1" HUGO_VERSION = "0.89.4"
[context.next.environment] [context.next.environment]
HUGO_ENABLEGITINFO = "true" HUGO_ENABLEGITINFO = "true"