summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-12-08 08:54:25 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-12-08 08:54:25 +0100
commit6c841a691ed567acdddffec84642326decf311ce (patch)
treeffce1423050960a847faf50ab75327015af85ec2 /docs
parente71d715b9b0c55aea7ef4fc88642eecd6e7b58c3 (diff)
parent8d9511a08f14260cbfb73119e4afae50e5a9966d (diff)
Diffstat (limited to 'docs')
-rw-r--r--docs/content/en/content-management/front-matter.md11
-rw-r--r--docs/content/en/content-management/image-processing/index.md2
-rw-r--r--docs/content/en/content-management/menus.md24
-rw-r--r--docs/content/en/content-management/multilingual.md209
-rw-r--r--docs/content/en/content-management/organization/index.md38
-rw-r--r--docs/content/en/content-management/page-resources.md17
-rw-r--r--docs/content/en/contribute/development.md2
-rw-r--r--docs/content/en/functions/GetPage.md4
-rw-r--r--docs/content/en/functions/dict.md2
-rw-r--r--docs/content/en/functions/fileExists.md34
-rw-r--r--docs/content/en/functions/getenv.md35
-rw-r--r--docs/content/en/functions/os.Stat.md28
-rw-r--r--docs/content/en/functions/readdir.md41
-rw-r--r--docs/content/en/functions/readfile.md31
-rw-r--r--docs/content/en/functions/substr.md2
-rw-r--r--docs/content/en/functions/unix.md38
-rw-r--r--docs/content/en/getting-started/code-toggle.md79
-rw-r--r--docs/content/en/getting-started/configuration.md45
-rw-r--r--docs/content/en/getting-started/installing.md8
-rw-r--r--docs/content/en/hosting-and-deployment/hosting-on-github.md8
-rw-r--r--docs/content/en/hosting-and-deployment/hosting-on-render.md2
-rw-r--r--docs/content/en/news/0.89.0-relnotes/featured.pngbin0 -> 104046 bytes
-rw-r--r--docs/content/en/news/0.89.0-relnotes/index.md20
-rw-r--r--docs/content/en/news/0.89.4-relnotes/index.md6
-rw-r--r--docs/content/en/showcase/aether/bio.md9
-rw-r--r--docs/content/en/showcase/aether/featured.pngbin275219 -> 0 bytes
-rw-r--r--docs/content/en/showcase/aether/index.md39
-rw-r--r--docs/content/en/showcase/arolla-cocoon/bio.md6
-rw-r--r--docs/content/en/showcase/arolla-cocoon/featured-template.pngbin451984 -> 0 bytes
-rw-r--r--docs/content/en/showcase/arolla-cocoon/index.md29
-rw-r--r--docs/content/en/showcase/pace-revenue-management/bio.md4
-rw-r--r--docs/content/en/showcase/pace-revenue-management/featured.pngbin298908 -> 0 bytes
-rw-r--r--docs/content/en/showcase/pace-revenue-management/index.md28
-rw-r--r--docs/content/en/templates/internal.md3
-rw-r--r--docs/content/en/templates/introduction.md99
-rw-r--r--docs/content/en/variables/site.md2
-rw-r--r--docs/layouts/shortcodes/code-toggle.html4
-rw-r--r--docs/layouts/template-func/page.html5
-rw-r--r--docs/netlify.toml8
-rw-r--r--docs/resources/_gen/images/news/0.66.0-relnotes/hugo-66-poster-featured_hu4d3a62a6d2ad42dd03e2a3723d4914a5_75588_640x0_resize_catmullrom_3.pngbin48752 -> 0 bytes
-rw-r--r--docs/resources/_gen/images/news/0.67.0-relnotes/hugo-67-poster-featured_hub9adb3c2f94f651d39a760315e4e42f9_79436_640x0_resize_catmullrom_3.pngbin49168 -> 0 bytes
-rw-r--r--docs/resources/_gen/images/news/0.68.0-relnotes/hugo-68-featured_hubf411be7de0d7016f242fc7f0c46d71c_65337_640x0_resize_catmullrom_3.pngbin41701 -> 0 bytes
-rw-r--r--docs/resources/_gen/images/news/0.89.0-relnotes/featured_hu8f869189eb2dd98af38fbcfa6bc2c5e7_104046_480x0_resize_catmullrom_3.pngbin0 -> 23201 bytes
-rw-r--r--docs/resources/_gen/images/news/0.89.0-relnotes/featured_hu8f869189eb2dd98af38fbcfa6bc2c5e7_104046_640x0_resize_catmullrom_3.pngbin0 -> 39069 bytes
-rw-r--r--docs/resources/_gen/images/showcase/aether/featured_hu087b0e6f87446792599d3d3535cdd374_275219_1024x512_fill_catmullrom_top_3.pngbin148835 -> 0 bytes
-rw-r--r--docs/resources/_gen/images/showcase/aether/featured_hu087b0e6f87446792599d3d3535cdd374_275219_f479f94112f3e0c5767e1193b5965779.pngbin49211 -> 0 bytes
-rw-r--r--docs/resources/_gen/images/showcase/arolla-cocoon/featured-template_hu22aab819ab27e4f878d1ff0b7cf78050_451984_0f50711b225daa7061d1303818804a06.pngbin67772 -> 0 bytes
-rw-r--r--docs/resources/_gen/images/showcase/arolla-cocoon/featured-template_hu22aab819ab27e4f878d1ff0b7cf78050_451984_1024x512_fill_catmullrom_top_3.pngbin227292 -> 0 bytes
48 files changed, 460 insertions, 462 deletions
diff --git a/docs/content/en/content-management/front-matter.md b/docs/content/en/content-management/front-matter.md
index 0353fb1fe..2155f1992 100644
--- a/docs/content/en/content-management/front-matter.md
+++ b/docs/content/en/content-management/front-matter.md
@@ -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`.
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
: 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.
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 multilingual feature.
+: 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).
videos
: 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
-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
@@ -202,9 +201,9 @@ cascade:
banner: images/typewriter.jpg
{{</ 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.
diff --git a/docs/content/en/content-management/image-processing/index.md b/docs/content/en/content-management/image-processing/index.md
index e2e964154..8f84145ac 100644
--- a/docs/content/en/content-management/image-processing/index.md
+++ b/docs/content/en/content-management/image-processing/index.md
@@ -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.
-Valid values are `jpg`, `png`, `tif`, `bmp`, `gif` and `webp`.
+Valid values are `bmp`, `gif`, `jpeg`, `jpg`, `png`, `tif`, `tiff`, and `webp`.
```go
{{ $image.Resize "600x jpg" }}
diff --git a/docs/content/en/content-management/menus.md b/docs/content/en/content-management/menus.md
index 6b89c44da..aefc99e00 100644
--- a/docs/content/en/content-management/menus.md
+++ b/docs/content/en/content-management/menus.md
@@ -12,7 +12,7 @@ menu:
docs:
parent: "content-management"
weight: 120
-weight: 120 #rem
+weight: 120
aliases: [/extras/menus/]
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
-```
----
+{{< code-toggle >}}
menu: "main"
----
-```
+{{< /code-toggle >}}
#### Multiple Menus
-```
----
+{{< code-toggle >}}
menu: ["main", "footer"]
----
-```
+{{< /code-toggle >}}
#### Advanced
-
-```
----
+{{< code-toggle >}}
menu:
docs:
parent: 'extras'
weight: 20
----
-```
+{{< /code-toggle >}}
## 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
-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.
@@ -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"
{{</ code-toggle >}}
-
## Render Menus
See [Menu Templates](/templates/menu-templates/) for information on how to render your site menus within your templates.
diff --git a/docs/content/en/content-management/multilingual.md b/docs/content/en/content-management/multilingual.md
index 5e7bed87c..c24c0ccc4 100644
--- a/docs/content/en/content-management/multilingual.md
+++ b/docs/content/en/content-management/multilingual.md
@@ -19,7 +19,7 @@ toc: true
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
@@ -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,
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`.
@@ -83,25 +83,24 @@ disableLanguages = ["fr", "ja"]
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
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:
```bash
HUGO_DISABLELANGUAGES=" " hugo server
```
-
### 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.
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.
Example:
@@ -123,7 +122,7 @@ title = "In English"
With the above, the two sites will be generated into `public` with their own root:
-```bash
+```text
public
├── en
└── 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:
-```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:1314 (bind address 127.0.0.1)
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:
-
{{< code-toggle file="config" >}}
[Taxonomies]
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 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.
@@ -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.
{{< code-toggle file="config" >}}
-
languages:
en:
weight: 10
@@ -205,7 +202,6 @@ languages:
weight: 20
languageName: "Français"
contentDir: "content/french"
-
{{< /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.
@@ -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.
-### 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.
@@ -232,19 +228,17 @@ Considering the following example:
2. `/content/om.nn.md`
3. `/content/presentation/a-propos.fr.md`
-```yaml
-# set in all three pages
+{{< code-toggle >}}
translationKey: "about"
-```
+{{< /code-toggle >}}
By setting the `translationKey` front matter param to `about` in all three pages, they will be __linked__ as translated pages.
-
### Localizing permalinks
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.
@@ -253,7 +247,6 @@ Title: A Propos
slug: "a-propos"
{{< /code-toggle >}}
-
At render, Hugo will build both `/about/` and `/fr/a-propos/` while maintaining their translation linking.
{{% note %}}
@@ -283,16 +276,16 @@ To create a list of links to translated content, use a template similar to the f
{{ if .IsTranslated }}
<h4>{{ i18n "translations" }}</h4>
<ul>
- {{ range .Translations }}
- <li>
- <a href="{{ .Permalink }}">{{ .Lang }}: {{ .Title }}{{ if .IsPage }} ({{ i18n "wordCount" . }}){{ end }}</a>
- </li>
- {{ end }}
+ {{ range .Translations }}
+ <li>
+ <a href="{{ .Permalink }}">{{ .Lang }}: {{ .Title }}{{ if .IsPage }} ({{ i18n "wordCount" . }}){{ end }}</a>
+ </li>
+ {{ end }}
</ul>
{{ end }}
{{< /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.
@@ -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:
-
{{< code file="layouts/partials/allLanguages.html" >}}
<ul>
{{ range $.Site.Home.AllTranslations }}
@@ -311,22 +303,24 @@ The above also uses the [`i18n` function][i18func] described in the next section
## 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 %}}
-From **Hugo 0.31** you no longer need to use a valid language code. It can be anything.
+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:
-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
From within your templates, use the `i18n` function like this:
-```
+```go-html-template
{{ i18n "home" }}
```
@@ -339,7 +333,7 @@ other = "Home"
The result will be
-```
+```text
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`:
-```
+```go-html-template
{{ 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:
-```
+```text
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.
-```
+```go-html-template
{{ 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:
-```
+```text
525600 minutes to read
```
If `.ReadingTime.Count` in the context has value is 1. The result is:
-```
+```text
One minute to read
```
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") }}
```
+## 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
-1: "janvier"
-2: "février"
-3: "mars"
-4: "avril"
-5: "mai"
-6: "juin"
-7: "juillet"
-8: "août"
-9: "septembre"
-10: "octobre"
-11: "novembre"
-12: "décembre"
-~~~
+[languages]
+[languages.en]
+contentDir = 'content/en'
+languageName = 'English'
+weight = 1
+[languages.fr]
+contentDir = 'content/fr'
+languageName = 'Français'
+weight = 2
+[languages.de]
+contentDir = 'content/de'
+languageName = 'Deutsch'
+weight = 3
-...then index the non-English date names in your templates like so:
+{{< /code-toggle >}}
-~~~html
-<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>
-~~~
+### Dates
-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