content: Replace note shortcode calls with blockquote alerts

This commit is contained in:
Joe Mooring
2025-03-08 06:00:23 -08:00
committed by GitHub
parent aef899bc54
commit c540e6d295
193 changed files with 1384 additions and 1976 deletions
+1
View File
@@ -60,6 +60,7 @@
"redirections",
"subexpression",
"suppressible",
"synchronisation",
"templating",
"transpile",
"unmarshal",
+1
View File
@@ -22,5 +22,6 @@ MD041: false
MD046: false
MD049: false
MD050: false
MD051: false
MD053: false
MD055: false
-1
View File
@@ -6,7 +6,6 @@ keywords: []
params:
functions_and_methods:
aliases: []
related: []
returnType:
signatures: []
---
-1
View File
@@ -5,7 +5,6 @@ categories: []
keywords: []
params:
functions_and_methods:
related: []
returnType:
signatures: []
---
+1 -1
View File
@@ -1,7 +1,7 @@
---
title: {{ replace .File.ContentBaseName "-" " " | strings.FirstUpper }}
publishDate: {{ .Date }}
description:
categories: []
keywords: []
publishDate: {{ .Date }}
---
+2 -3
View File
@@ -2,8 +2,7 @@
_comment: Do not remove front matter.
---
{{< note >}}
The [page collections quick reference guide] describes methods and functions to filter, sort, and group page collections.
> [!note]
> The [page collections quick reference guide] describes methods and functions to filter, sort, and group page collections.
[page collections quick reference guide]: /quick-reference/page-collections/
{{< /note >}}
+2 -3
View File
@@ -2,8 +2,7 @@
_comment: Do not remove front matter.
---
{{< note >}}
Localization of dates, currencies, numbers, and percentages is performed by the [gohugoio/locales] package. The language tag of the current site must match one of the listed locales.
> [!note]
> Localization of dates, currencies, numbers, and percentages is performed by the [gohugoio/locales] package. The language tag of the current site must match one of the listed locales.
[gohugoio/locales]: https://github.com/gohugoio/locales
{{< /note >}}
@@ -1,8 +0,0 @@
---
_comment: Do not remove front matter.
---
If you are a Windows user, and the path to your project contains a space, you must place the PostCSS configuration within the package.json file. See [this example] and issue [#7333].
[this example]: https://github.com/postcss/postcss-load-config#packagejson
[#7333]: https://github.com/gohugoio/hugo/issues/7333
+13
View File
@@ -0,0 +1,13 @@
---
_comment: Do not remove front matter.
---
> [!warning] Hugo Modules are Go Modules
> You need [Go] version 1.18 or later and [Git] to use Hugo Modules. For older sites hosted on Netlify, please ensure the `GO_VERSION` environment variable is set to `1.18` or higher.
>
> Go Modules resources:
> - [go.dev/wiki/Modules](https://go.dev/wiki/Modules)
> - [blog.golang.org/using-go-modules](https://go.dev/blog/using-go-modules)
[Git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
[Go]: https://go.dev/doc/install
@@ -2,6 +2,5 @@
_comment: Do not remove front matter.
---
{{< note >}}
Use this method with [global resources](g), [page resources](g), or [remote resources](g).
{{< /note >}}
> [!note]
> Use this method with [global resources](g), [page resources](g), or [remote resources](g).
+7 -8
View File
@@ -33,16 +33,15 @@ Any render hook triggered while rendering `/posts/p2` will get:
`PageInner` falls back to the value of `Page` if not relevant, and always returns a value.
{{< note >}}
The `PageInner` method is only relevant for shortcodes that invoke the [`RenderShortcodes`] method, and you must call the shortcode using [Markdown notation].
[Markdown notation]: /content-management/shortcodes/#notation
[`RenderShortcodes`]: /methods/page/rendershortcodes/
{{< /note >}}
> [!note]
> The `PageInner` method is only relevant for shortcodes that invoke the [`RenderShortcodes`] method, and you must call the shortcode using [Markdown notation].
As a practical example, Hugo's embedded link and image render hooks use the `PageInner` method to resolve markdown link and image destinations. See the source code for each:
- [Embedded link render hook]({{% eturl render-link %}})
- [Embedded image render hook]({{% eturl render-image %}})
- [Embedded link render hook]
- [Embedded image render hook]
[`RenderShortcodes`]: /methods/page/rendershortcodes/
[Markdown notation]: /content-management/shortcodes/#notation
[Embedded link render hook]: {{% eturl render-link %}}
[Embedded image render hook]: {{% eturl render-image %}}
@@ -11,9 +11,8 @@ codeFences
guessSyntax
: (`bool`) Whether to automatically detect the language if the `LANG` argument is blank or set to a language for which there is no corresponding [lexer](g). Falls back to a plain text lexer if unable to automatically detect the language. Default is `false`.
{{< note >}}
The Chroma syntax highlighter includes lexers for approximately 250 languages, but only 5 of these have implemented automatic language detection.
{{< /note >}}
> [!note]
> The Chroma syntax highlighter includes lexers for approximately 250 languages, but only 5 of these have implemented automatic language detection.
hl_Lines
: (`string`) A space-delimited list of lines to emphasize within the highlighted code. To emphasize lines 2, 3, 4, and 7, set this value to `2-4 7`. This option is independent of the `lineNoStart` option.
@@ -28,7 +27,11 @@ lineNoStart
: (`int`) The number to display at the beginning of the first line. Irrelevant if `lineNos` is `false`. Default is `1`.
lineNos
: (`bool`) Whether to display a number at the beginning of each line. Default is `false`.
: (`any`) Controls line number display. Default is `false`.
- `true`: Enable line numbers, controlled by `lineNumbersInTable`.
- `false`: Disable line numbers.
- `inline`: Enable inline line numbers (sets `lineNumbersInTable` to `false`).
- `table`: Enable table-based line numbers (sets `lineNumbersInTable` to `true`).
lineNumbersInTable
: (`bool`) Whether to render the highlighted code in an HTML table with two cells. The left table cell contains the line numbers, while the right table cell contains the code. Irrelevant if `lineNos` is `false`. Default is `true`.
@@ -50,16 +53,4 @@ wrapperClass
: {{< new-in 0.140.2 />}}
: (`string`) The class or classes to use for the outermost element of the highlighted code. Default is `highlight`.
{{< note >}}
Instead of specifying both `lineNos` and `lineNumbersInTable`, you can use the following shorthand notation:
lineNos=inline
: equivalent to `lineNos=true` and `lineNumbersInTable=false`
lineNos=table
: equivalent to `lineNos=true` and `lineNumbersInTable=true`
{{< /note >}}
[Short snippets]: https://xyproto.github.io/splash/docs/all.html
[Long snippets]: https://xyproto.github.io/splash/docs/longer/all.html
[syntax highlighting styles]: /quick-reference/syntax-highlighting-styles/
+1 -1
View File
@@ -78,7 +78,7 @@ weight: 20
## Asset pipelines
[Image processing]
: Convert, resize, crop, rotate, adjust colors, apply filters, overlay text and images, and extract EXIF data.
: Convert, resize, crop, rotate, adjust colors, apply filters, overlay text and images, and extract EXIF data.
[JavaScript bundling]
: Transpile TypeScript and JSX to JavaScript, bundle, tree shake, minify, create source maps, and perform SRI hashing.
+30 -32
View File
@@ -294,28 +294,6 @@ titleCaseStyle
uglyurls
: See [configure ugly URLs](/configuration/ugly-urls/).
[IANA Time Zone Database]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
[RFC 5646]: https://datatracker.ietf.org/doc/html/rfc5646#section-2.1
[`FuzzyWordCount`]: /methods/page/fuzzywordcount/
[`GitInfo`]: /methods/page/gitinfo/
[`MainSections`]: /methods/site/mainsections/
[`Summary`]: /methods/page/summary/
[`WordCount`]: /methods/page/wordcount/
[`disabled`]: /configuration/languages/#disabled
[`erroridf`]: /functions/fmt/erroridf/
[`segments`]: /configuration/segments/
[`strings.Title`]: /functions/strings/title
[`time.AsTime`]: /functions/time/astime/
[`time.Format`]: /functions/time/format/
[`warnidf`]: /functions/fmt/warnidf/
[automatic summaries]: /content-management/summaries/#automatic-summary
[default front matter configuration]: /configuration/front-matter/
[duration]: https://pkg.go.dev/time#Duration
[embedded Open Graph template]: {{% eturl opengraph %}}
[embedded RSS template]: {{% eturl rss %}}
[embedded alias template]: {{% eturl alias %}}
[module mounts]: /configuration/module/#mounts
## Cache directory
Hugo's file cache directory is configurable via the [`cacheDir`] configuration option or the `HUGO_CACHEDIR` environment variable. If neither is set, Hugo will use, in order of preference:
@@ -330,11 +308,6 @@ To determine the current `cacheDir`:
hugo config | grep cachedir
```
[XDG base directory specification]: https://specifications.freedesktop.org/basedir-spec/latest/
[`cacheDir`]: #cachedir
[os.UserCacheDir]: https://pkg.go.dev/os#UserCacheDir
[this configuration]: https://github.com/bep/hugo-sass-test/blob/6c3960a8f4b90e8938228688bc49bdcdd6b2d99e/.circleci/config.yml
## Title case style
Hugo's [`titleCaseStyle`] setting governs capitalization for automatically generated section titles and the [`strings.Title`] function. By default, it follows the capitalization rules published in the Associated Press Stylebook. Change this setting to use other capitalization rules.
@@ -354,11 +327,36 @@ firstupper
none
: Disable transformation of automatic section titles, and disable the transformation performed by the `strings.Title` function. This is useful if you would prefer to manually capitalize section titles as needed, and to bypass opinionated theme usage of the `strings.Title` function.
[Associated Press Stylebook]: https://www.apstylebook.com/
[Chicago Manual of Style]: https://www.chicagomanualofstyle.org/home.html
[`strings.Title`]: /functions/strings/title/
[`titleCaseStyle`]: #titlecasestyle
## Localized settings
Some configuration settings, such as menus and custom parameters, can be defined separately for each language. See [configure languages](/configuration/languages/#localized-settings).
[`cacheDir`]: #cachedir
[`disabled`]: /configuration/languages/#disabled
[`erroridf`]: /functions/fmt/erroridf/
[`FuzzyWordCount`]: /methods/page/fuzzywordcount/
[`GitInfo`]: /methods/page/gitinfo/
[`MainSections`]: /methods/site/mainsections/
[`segments`]: /configuration/segments/
[`strings.Title`]: /functions/strings/title/
[`strings.Title`]: /functions/strings/title
[`Summary`]: /methods/page/summary/
[`time.AsTime`]: /functions/time/astime/
[`time.Format`]: /functions/time/format/
[`titleCaseStyle`]: #titlecasestyle
[`warnidf`]: /functions/fmt/warnidf/
[`WordCount`]: /methods/page/wordcount/
[Associated Press Stylebook]: https://www.apstylebook.com/
[automatic summaries]: /content-management/summaries/#automatic-summary
[Chicago Manual of Style]: https://www.chicagomanualofstyle.org/home.html
[default front matter configuration]: /configuration/front-matter/
[duration]: https://pkg.go.dev/time#Duration
[embedded alias template]: {{% eturl alias %}}
[embedded Open Graph template]: {{% eturl opengraph %}}
[embedded RSS template]: {{% eturl rss %}}
[IANA Time Zone Database]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
[module mounts]: /configuration/module/#mounts
[os.UserCacheDir]: https://pkg.go.dev/os#UserCacheDir
[RFC 5646]: https://datatracker.ietf.org/doc/html/rfc5646#section-2.1
[this configuration]: https://github.com/bep/hugo-sass-test/blob/6c3960a8f4b90e8938228688bc49bdcdd6b2d99e/.circleci/config.yml
[XDG base directory specification]: https://specifications.freedesktop.org/basedir-spec/latest/
+6 -7
View File
@@ -71,12 +71,11 @@ disableTags
disableClasses
: (`bool`) Whether to exclude `class` attributes. Default is `false`.
{{< note >}}
Given that CSS purging is typically limited to production builds, place the `buildStats` object below [`config/production`].
[`config/production`]: /configuration/introduction/#configuration-directory
Built for speed, there may be "false positive" detections (e.g., HTML elements that are not HTML elements) while parsing the published site. These "false positives" are infrequent and inconsequential.
{{< /note >}}
> [!note]
> Given that CSS purging is typically limited to production builds, place the `buildStats` object below [`config/production`].
>
> Built for speed, there may be "false positive" detections (e.g., HTML elements that are not HTML elements) while parsing the published site. These "false positives" are infrequent and inconsequential.
Due to the nature of partial server builds, new HTML entities are added while the server is running, but old values will not be removed until you restart the server or run a regular `hugo` build.
[`config/production`]: /configuration/introduction/#configuration-directory
+5 -7
View File
@@ -8,11 +8,8 @@ keywords: []
You can configure your site to cascade front matter values to the home page and any of its descendants. However, this cascading will be prevented if the descendant already defines the field, or if a closer ancestor [node](g) has already cascaded a value for the same field through its front matter's `cascade` key.
{{< note >}}
You can also configure cascading behavior within a page's front matter. See&nbsp;[details].
[details]: /content-management/front-matter/#cascade-1
{{< /note >}}
> [!note]
> You can also configure cascading behavior within a page's front matter. See&nbsp;[details].
For example, to cascade a "color" parameter to the home page and all its descendants:
@@ -55,8 +52,6 @@ lang
path
: (`string`) A [glob](g) pattern matching the page's [logical path](g). For example: `{/books,/books/**}`.
[page language]: /methods/page/language/
## Array
Define an array of cascade parameters to apply different values to different targets. For example:
@@ -77,3 +72,6 @@ path = '{/films/**}'
kind = 'page'
environment = 'production'
{{< /code-toggle >}}
[details]: /content-management/front-matter/#cascade-1
[page language]: /methods/page/language/
+2 -3
View File
@@ -6,9 +6,8 @@ categories: []
keywords: []
---
{{< note >}}
This configuration is only relevant when running `hugo deploy`. See&nbsp;[details](/host-and-deploy/deploy-with-hugo-deploy/).
{{< /note >}}
> [!note]
> This configuration is only relevant when running `hugo deploy`. See&nbsp;[details](/host-and-deploy/deploy-with-hugo-deploy/).
## Top-level options
+6 -9
View File
@@ -6,11 +6,8 @@ categories: []
keywords: []
---
{{< note >}}
This configuration is only relevant when using the [`resources.GetRemote`] function.
[`resources.GetRemote`]: /functions/resources/getremote/
{{< /note >}}
> [!note]
> This configuration is only relevant when using the [`resources.GetRemote`] function.
## Layered caching
@@ -41,10 +38,6 @@ HTTP Cache
File cache
: See [configure file caches].
[cache-busting]: /configuration/build/#cache-busters
[RFC 9111]: https://datatracker.ietf.org/doc/html/rfc9111
[configure file caches]: /configuration/caches/
The HTTP cache involves two key aspects: determining which content to cache (the caching process itself) and defining the frequency with which to check for updates (the polling strategy).
## HTTP caching
@@ -107,4 +100,8 @@ Polling and HTTP caching interact as follows:
- If polling is enabled but HTTP caching is disabled, the remote is checked for changes only after the file cache's TTL expires (e.g., a `maxAge` of `10h` with a `1s` polling interval is inefficient).
- If both polling and HTTP caching are enabled, changes are checked for even before the file cache's TTL expires. Cached `eTag` and `last-modified` values are sent in `if-none-match` and `if-modified-since` headers, respectively, and a cached response is returned on HTTP [304].
[`resources.GetRemote`]: /functions/resources/getremote/
[304]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/304
[cache-busting]: /configuration/build/#cache-busters
[configure file caches]: /configuration/caches/
[RFC 9111]: https://datatracker.ietf.org/doc/html/rfc9111
+4 -5
View File
@@ -60,8 +60,7 @@ excludeFields
includeFields
: (`string`) A regular expression matching the tags to include when extracting EXIF data. To include all available tags, set this value to&nbsp;`".*"`.
{{< note >}}
To improve performance and decrease cache size, Hugo excludes the following tags: `ColorSpace`, `Contrast`, `Exif`, `Exposure[M|P|B]`, `Flash`, `GPS`, `JPEG`, `Metering`, `Resolution`, `Saturation`, `Sensing`, `Sharp`, and `WhiteBalance`.
To control tag availability, change the `excludeFields` or `includeFields` settings as described above.
{{< /note >}}
> [!note]
> To improve performance and decrease cache size, Hugo excludes the following tags: `ColorSpace`, `Contrast`, `Exif`, `Exposure[M|P|B]`, `Flash`, `GPS`, `JPEG`, `Metering`, `Resolution`, `Saturation`, `Sensing`, `Sharp`, and `WhiteBalance`.
>
> To control tag availability, change the `excludeFields` or `includeFields` settings as described above.
+21 -31
View File
@@ -18,9 +18,8 @@ title = 'My New Hugo Site'
Only define settings that deviate from the defaults. A smaller configuration file is easier to read, understand, and debug. Keep your configuration concise.
{{< note >}}
The best configuration file is a short configuration file.
{{< /note >}}
> [!note]
> The best configuration file is a short configuration file.
## Configuration file
@@ -31,9 +30,8 @@ my-project/
└── hugo.toml
```
{{< note >}}
For versions v0.109.0 and earlier, the site configuration file was named `config`. While you can still use this name, it's recommended to switch to the newer naming convention, `hugo`.
{{< /note >}}
> [!note]
> For versions v0.109.0 and earlier, the site configuration file was named `config`. While you can still use this name, it's recommended to switch to the newer naming convention, `hugo`.
A simple example:
@@ -60,13 +58,8 @@ Combine two or more configuration files, with left-to-right precedence:
hugo --config a.toml,b.yaml,c.json
```
{{< note >}}
See the specifications for each file format: [TOML], [YAML], and [JSON].
[TOML]: https://toml.io/en/latest
[YAML]: https://yaml.org/spec/
[JSON]: https://datatracker.ietf.org/doc/html/rfc7159
{{< /note >}}
> [!note]
> See the specifications for each file format: [TOML], [YAML], and [JSON].
## Configuration directory
@@ -135,8 +128,6 @@ Considering the structure above, when running `hugo --environment staging`, Hugo
Let's take an example to understand this better. Let's say you are using Google Analytics for your website. This requires you to specify a [Google tag ID] in your site configuration:
[Google tag ID]: https://support.google.com/tagmanager/answer/12326985?hl=en
{{< code-toggle file=hugo >}}
[services.googleAnalytics]
ID = 'G-XXXXXXXXX'
@@ -236,28 +227,18 @@ hugo
The above sets the [`baseURL`], [`enableGitInfo`], and [`environment`] configuration options and then builds your site.
[`baseURL`]: /configuration/all#baseurl
[`enableGitInfo`]: /configuration/all#enablegitinfo
[`environment`]: /configuration/all#environment
{{< note >}}
An environment variable takes precedence over the values set in the configuration file. This means that if you set a configuration value with both an environment variable and in the configuration file, the value in the environment variable will be used.
{{< /note >}}
> [!note]
> An environment variable takes precedence over the values set in the configuration file. This means that if you set a configuration value with both an environment variable and in the configuration file, the value in the environment variable will be used.
Environment variables simplify configuration for CI/CD deployments like GitHub Pages, GitLab Pages, and Netlify by allowing you to set values directly within their respective configuration and workflow files.
[CI/CD]: https://en.wikipedia.org/wiki/CI/CD
{{< note >}}
Environment variable names must be prefixed with `HUGO_`.
To set custom site parameters, prefix the name with `HUGO_PARAMS_`.
{{< /note >}}
> [!note]
> Environment variable names must be prefixed with `HUGO_`.
>
> To set custom site parameters, prefix the name with `HUGO_PARAMS_`.
For snake_case variable names, the standard `HUGO_` prefix won't work. Hugo infers the delimiter from the first character following `HUGO`. This allows for variations like `HUGOxPARAMSxAPI_KEY=abcdefgh` using any [permitted delimiter].
[permitted delimiter]: https://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html
In addition to configuring standard settings, environment variables may be used to override default values for certain internal settings:
DART_SASS_BINARY
@@ -292,3 +273,12 @@ Display the configured file mounts with:
```sh
hugo config mounts
```
[`baseURL`]: /configuration/all#baseurl
[`enableGitInfo`]: /configuration/all#enablegitinfo
[`environment`]: /configuration/all#environment
[Google tag ID]: https://support.google.com/tagmanager/answer/12326985?hl=en
[JSON]: https://datatracker.ietf.org/doc/html/rfc7159
[permitted delimiter]: https://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html
[TOML]: https://toml.io/en/latest
[YAML]: https://yaml.org/spec/
+19 -25
View File
@@ -30,8 +30,6 @@ disableDefaultLanguageRedirect
disableLanguages
: (`[]string]`) A slice of language keys representing the languages to disable during the build process. Although this is functional, consider using the [`disabled`](#disabled) key under each language instead.
[RFC 5646]: https://datatracker.ietf.org/doc/html/rfc5646#section-2.1
## Language settings
Configure each language under the `languages` key:
@@ -64,16 +62,6 @@ title
weight
: (`int`) The language [weight](g). When set to a non-zero value, this is the primary sort criteria for this language. Access this value from a template using the [`Language.Weight`] method on a `Site` or `Page` object.
[`Language.LanguageCode`]: /methods/site/language/#languagecode
[`Language.LanguageDirection`]: /methods/site/language/#languagedirection
[`Language.LanguageName`]: /methods/site/language/#languagename
[`Language.Weight`]: /methods/site/language/#weight
[`Title`]: /methods/site/title/
[`dir`]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir
[built-in OpenGraph template]: {{% eturl opengraph %}}
[built-in RSS template]: {{% eturl rss %}}
[built-in alias template]: {{% eturl alias %}}
## Localized settings
Some configuration settings can be defined separately for each language. For example:
@@ -121,11 +109,8 @@ weight = 1
weight = 2
{{< /code-toggle >}}
{{< note >}}
Private use subtags must not exceed 8 alphanumeric characters.
{{< /note >}}
[RFC 5646 § 2.2.7]: https://datatracker.ietf.org/doc/html/rfc5646#section-2.2.7
> [!note]
> Private use subtags must not exceed 8 alphanumeric characters.
## Example
@@ -159,19 +144,15 @@ weight = 2
subtitle = 'Reference, Tutorials, and Explanations'
{{< /code-toggle >}}
{{< note >}}
In the example above, omit `contentDir` if [translating by file name].
[translating by file name]: /content-management/multilingual/#translation-by-file-name
{{< /note >}}
> [!note]
> In the example above, omit `contentDir` if [translating by file name].
## Multihost
Hugo supports multiple languages in a multihost configuration. This means you can configure a `baseURL` per `language`.
{{< note >}}
If you define a `baseURL` for one language, you must define a unique `baseURL` for all languages.
{{< /note >}}
> [!note]
> If you define a `baseURL` for one language, you must define a unique `baseURL` for all languages.
For example:
@@ -197,3 +178,16 @@ public
├── en
└── fr
```
[`dir`]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir
[`Language.LanguageCode`]: /methods/site/language/#languagecode
[`Language.LanguageDirection`]: /methods/site/language/#languagedirection
[`Language.LanguageName`]: /methods/site/language/#languagename
[`Language.Weight`]: /methods/site/language/#weight
[`Title`]: /methods/site/title/
[built-in alias template]: {{% eturl alias %}}
[built-in OpenGraph template]: {{% eturl opengraph %}}
[built-in RSS template]: {{% eturl rss %}}
[RFC 5646]: https://datatracker.ietf.org/doc/html/rfc5646#section-2.1
[RFC 5646 § 2.2.7]: https://datatracker.ietf.org/doc/html/rfc5646#section-2.2.7
[translating by file name]: /content-management/multilingual/#translation-by-file-name
+45 -63
View File
@@ -30,20 +30,8 @@ To use a different renderer for Markdown files, specify one of `asciidocext`, `o
To use AsciiDoc, Pandoc, or reStructuredText you must install the relevant renderer and update your [security policy].
{{< note >}}
Unless you need a unique capability provided by one of the alternative Markdown handlers, we strongly recommend that you use the default setting. Goldmark is fast, well maintained, conforms to the [CommonMark] specification, and is compatible with [GitHub Flavored Markdown] (GFM).
[commonmark]: https://spec.commonmark.org/0.30/
[github flavored markdown]: https://github.github.com/gfm/
{{< /note >}}
[asciidoc]: https://asciidoc.org/
[content format]: /content-management/formats/#formats
[emacs org mode]: https://orgmode.org/
[goldmark]: https://github.com/yuin/goldmark/
[pandoc]: https://pandoc.org/
[restructuredtext]: https://docutils.sourceforge.io/rst.html
[security policy]: /configuration/security/
> [!note]
> Unless you need a unique capability provided by one of the alternative Markdown handlers, we strongly recommend that you use the default setting. Goldmark is fast, well maintained, conforms to the [CommonMark] specification, and is compatible with [GitHub Flavored Markdown] (GFM).
## Goldmark
@@ -68,17 +56,6 @@ Extension|Documentation|Enabled
`taskList`|[GitHub Flavored Markdown: Task list items]|:heavy_check_mark:
`typographer`|[Goldmark Extensions: Typographer]|:heavy_check_mark:
[GitHub Flavored Markdown: Autolinks]: https://github.github.com/gfm/#autolinks-extension-
[GitHub Flavored Markdown: Strikethrough]: https://github.github.com/gfm/#strikethrough-extension-
[GitHub Flavored Markdown: Tables]: https://github.github.com/gfm/#tables-extension-
[GitHub Flavored Markdown: Task list items]: https://github.github.com/gfm/#task-list-items-extension-
[Goldmark Extensions: CJK]: https://github.com/yuin/goldmark?tab=readme-ov-file#cjk-extension
[Goldmark Extensions: Typographer]: https://github.com/yuin/goldmark?tab=readme-ov-file#typographer-extension
[Hugo Goldmark Extensions: Extras]: https://github.com/gohugoio/hugo-goldmark-extensions?tab=readme-ov-file#extras-extension
[Hugo Goldmark Extensions: Passthrough]: https://github.com/gohugoio/hugo-goldmark-extensions?tab=readme-ov-file#passthrough-extension
[PHP Markdown Extra: Definition lists]: https://michelf.ca/projects/php-markdown/extra/#def-list
[PHP Markdown Extra: Footnotes]: https://michelf.ca/projects/php-markdown/extra/#footnotes
#### Extras
{{< new-in 0.126.0 />}}
@@ -93,12 +70,6 @@ Mark text|`==baz==`|`<mark>baz</mark>`
Subscript|`H~2~O`|`H<sub>2</sub>O`
Superscript|`1^st^`|`1<sup>st</sup>`
[deleted text]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/del
[inserted text]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ins
[mark text]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/mark
[subscript]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub
[superscript]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup
To avoid a conflict when enabling the "subscript" feature of the Extras extension, if you want to render subscript and strikethrough text concurrently you must:
1. Disable the Strikethrough extension
@@ -123,8 +94,6 @@ enable = true
Enable the Passthrough extension to include mathematical equations and expressions in Markdown using LaTeX markup. See [mathematics in Markdown] for details.
[mathematics in Markdown]: content-management/mathematics/
#### Typographer
The Typographer extension replaces certain character combinations with HTML entities as specified below:
@@ -150,12 +119,8 @@ duplicateResourceFiles
: {{< new-in 0.123.0 />}}
: (`bool`) Whether to duplicate shared page resources for each language on multilingual single-host sites. See [multilingual page resources] for details. Default is `false`.
{{< note >}}
With multilingual single-host sites, setting this parameter to `false` will enable Hugo's [embedded link render hook] and [embedded image render hook]. This is the default configuration for multilingual single-host sites.
[embedded image render hook]: /render-hooks/images/#default
[embedded link render hook]: /render-hooks/links/#default
{{< /note >}}
> [!note]
> With multilingual single-host sites, setting this parameter to `false` will enable Hugo's [embedded link render hook] and [embedded image render hook]. This is the default configuration for multilingual single-host sites.
parser.wrapStandAloneImageWithinParagraph
: (`bool`) Whether to wrap image elements without adjacent content within a `p` element when rendered. This is the default Markdown behavior. Set to `false` when using an [image render hook] to render standalone images as `figure` elements. Default is `true`.
@@ -186,21 +151,15 @@ renderHooks.image.enableDefault
: {{< new-in 0.123.0 />}}
: (`bool`) Whether to enable the [embedded image render hook]. Default is `false`.
{{< note >}}
The embedded image render hook is automatically enabled for multilingual single-host sites if [duplication of shared page resources] is disabled. This is the default configuration for multilingual single-host sites.
[duplication of shared page resources]: /configuration/markup/#duplicateresourcefiles
{{< /note >}}
> [!note]
> The embedded image render hook is automatically enabled for multilingual single-host sites if [duplication of shared page resources] is disabled. This is the default configuration for multilingual single-host sites.
renderHooks.link.enableDefault
: {{< new-in 0.123.0 />}}
: (`bool`) Whether to enable the [embedded link render hook]. Default is `false`.
{{< note >}}
The embedded link render hook is automatically enabled for multilingual single-host sites if [duplication of shared page resources] is disabled. This is the default configuration for multilingual single-host sites.
[duplication of shared page resources]: /configuration/markup/#duplicateresourcefiles
{{< /note >}}
> [!note]
> The embedded link render hook is automatically enabled for multilingual single-host sites if [duplication of shared page resources] is disabled. This is the default configuration for multilingual single-host sites.
renderer.hardWraps
: (`bool`) Whether to replace newline characters within a paragraph with `br` elements. Default is `false`.
@@ -208,12 +167,6 @@ renderer.hardWraps
renderer.unsafe
: (`bool`) Whether to render raw HTML mixed within Markdown. This is unsafe unless the content is under your control. Default is `false`.
[Markdown attributes]: /content-management/markdown-attributes/
[embedded image render hook]: /render-hooks/images/#default
[embedded link render hook]: /render-hooks/links/#default
[image render hook]: /render-hooks/images/
[multilingual page resources]: /content-management/page-resources/#multilingual
[`Fragments.Identifiers`]: /methods/page/fragments/#identifiers
## AsciiDoc
This is the default configuration for the AsciiDoc renderer:
@@ -231,9 +184,8 @@ backend
extensions
: (`string array`) An array of enabled extensions, one or more of `asciidoctor-html5s`, `asciidoctor-bibtex`, `asciidoctor-diagram`, `asciidoctor-interdoc-reftext`, `asciidoctor-katex`, `asciidoctor-latex`, `asciidoctor-mathematical`, or `asciidoctor-question`.
{{< note >}}
To mitigate security risks, entries in the extension array may not contain forward slashes (`/`), backslashes (`\`), or periods. Due to this restriction, extensions must be in Ruby's `$LOAD_PATH`.
{{< /note >}}
> [!note]
> To mitigate security risks, entries in the extension array may not contain forward slashes (`/`), backslashes (`\`), or periods. Due to this restriction, extensions must be in Ruby's `$LOAD_PATH`.
failureLevel
: (`string`) The minimum logging level that triggers a non-zero exit code (failure). Default is `fatal`.
@@ -259,11 +211,6 @@ verbose
workingFolderCurrent
: (`bool`) Whether to set the working directory to be the same as that of the AsciiDoc file being processed, allowing [includes] to work with relative paths. Set to `true` to render diagrams with the [asciidoctor-diagram] extension. Default is `false`.
[`TableOfContents`]: /methods/page/tableofcontents/
[asciidoctor-diagram]: https://asciidoctor.org/docs/asciidoctor-diagram/
[attributes]: https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#attributes-and-substitutions
[includes]: https://docs.asciidoctor.org/asciidoc/latest/syntax-quick-reference/#includes
### Configuration example
{{< code-toggle file=hugo >}}
@@ -353,3 +300,38 @@ endLevel
ordered
: (`bool`) Whether to generates an ordered list instead of an unordered list. Default is `false`.
[`Fragments.Identifiers`]: /methods/page/fragments/#identifiers
[`TableOfContents`]: /methods/page/tableofcontents/
[asciidoctor-diagram]: https://asciidoctor.org/docs/asciidoctor-diagram/
[attributes]: https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#attributes-and-substitutions
[CommonMark]: https://spec.commonmark.org/current/
[deleted text]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/del
[duplication of shared page resources]: /configuration/markup/#duplicateresourcefiles
[duplication of shared page resources]: /configuration/markup/#duplicateresourcefiles
[embedded image render hook]: /render-hooks/images/#default
[embedded image render hook]: /render-hooks/images/#default
[embedded link render hook]: /render-hooks/links/#default
[embedded link render hook]: /render-hooks/links/#default
[GitHub Flavored Markdown]: https://github.github.com/gfm/
[GitHub Flavored Markdown: Autolinks]: https://github.github.com/gfm/#autolinks-extension-
[GitHub Flavored Markdown: Strikethrough]: https://github.github.com/gfm/#strikethrough-extension-
[GitHub Flavored Markdown: Tables]: https://github.github.com/gfm/#tables-extension-
[GitHub Flavored Markdown: Task list items]: https://github.github.com/gfm/#task-list-items-extension-
[Goldmark]: https://github.com/yuin/goldmark/
[Goldmark Extensions: CJK]: https://github.com/yuin/goldmark?tab=readme-ov-file#cjk-extension
[Goldmark Extensions: Typographer]: https://github.com/yuin/goldmark?tab=readme-ov-file#typographer-extension
[Hugo Goldmark Extensions: Extras]: https://github.com/gohugoio/hugo-goldmark-extensions?tab=readme-ov-file#extras-extension
[Hugo Goldmark Extensions: Passthrough]: https://github.com/gohugoio/hugo-goldmark-extensions?tab=readme-ov-file#passthrough-extension
[image render hook]: /render-hooks/images/
[includes]: https://docs.asciidoctor.org/asciidoc/latest/syntax-quick-reference/#includes
[inserted text]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ins
[mark text]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/mark
[Markdown attributes]: /content-management/markdown-attributes/
[mathematics in Markdown]: content-management/mathematics/
[multilingual page resources]: /content-management/page-resources/#multilingual
[PHP Markdown Extra: Definition lists]: https://michelf.ca/projects/php-markdown/extra/#def-list
[PHP Markdown Extra: Footnotes]: https://michelf.ca/projects/php-markdown/extra/#footnotes
[security policy]: /configuration/security/
[subscript]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub
[superscript]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup
+2 -3
View File
@@ -14,9 +14,8 @@ Configured media types serve multiple purposes in Hugo, including the definition
The `suffixes` column in the table above shows the suffixes associated with each media type. For example, Hugo associates `.html` and `.htm` files with the `text/html` media type.
{{< note >}}
The first suffix is the primary suffix. Use the primary suffix when naming template files. For example, when creating a template for an RSS feed, use the `xml` suffix.
{{< /note >}}
> [!note]
> The first suffix is the primary suffix. Use the primary suffix when naming template files. For example, when creating a template for an RSS feed, use the `xml` suffix.
## Default configuration
+8 -10
View File
@@ -6,11 +6,8 @@ categories: []
keywords: []
---
{{< note >}}
To understand Hugo's menu system, please refer to the [menus] page.
[menus]: /content-management/menus/
{{< /note >}}
> [!note]
> To understand Hugo's menu system, please refer to the [menus] page.
There are three ways to define menu entries:
@@ -73,11 +70,6 @@ Access this menu structure in the same way:
{{ end }}
```
[Automatically]: /content-management/menus/#define-automatically
[In front matter]: /content-management/menus/#define-in-front-matter
[`Menus`]: /methods/site/menus/
[menu templates]: /templates/menu/
## Properties
Menu entries usually include at least three properties: `name`, `weight`, and either `pageRef` or `url`. Use `pageRef` for internal page destinations and `url` for external destinations.
@@ -135,3 +127,9 @@ weight = 30
[menus.main.params]
rel = 'external'
{{< /code-toggle >}}
[`Menus`]: /methods/site/menus/
[Automatically]: /content-management/menus/#define-automatically
[In front matter]: /content-management/menus/#define-in-front-matter
[menu templates]: /templates/menu/
[menus]: /content-management/menus/
+6 -8
View File
@@ -59,7 +59,7 @@ export HUGO_MODULE_REPLACEMENTS="github.com/bep/my-theme -> ../.."
export HUGO_MODULE_WORKSPACE="/my/hugo.work"
```
{{< gomodules-info >}}
{{% include "/_common/gomodules-info.md" %}}
## Hugo version
@@ -114,7 +114,7 @@ path
[`themesDir`]: /configuration/all#themesDir
{{< gomodules-info >}}
{{% include "/_common/gomodules-info.md" %}}
## Mounts
@@ -129,15 +129,13 @@ you cannot use both.
[`layoutDi`]: /configuration/all/
[`staticDir`]: /configuration/all/
{{< note >}}
If you use module mounts do not use the legacy settings.
{{< /note >}}
> [!note]
> If you use module mounts do not use the legacy settings.
### Default mounts
{{< note >}}
Adding a new mount to a target root will cause the existing default mount for that root to be ignored. If you still need the default mount, you must explicitly add it along with the new mount.
{{< /note >}}
> [!note]
> Adding a new mount to a target root will cause the existing default mount for that root to be ignored. If you still need the default mount, you must explicitly add it along with the new mount.
The are the default mounts:
+11 -13
View File
@@ -10,8 +10,6 @@ keywords: []
Learn more about creating and configuring output formats in the [configure output formats] section.
[configure output formats]: /configuration/output-formats/
## Outputs per page kind
The following default configuration determines the output formats generated for each page kind:
@@ -27,17 +25,12 @@ home = ['html','rss','json']
Notice in this example that we only specified the `home` page kind. You don't need to include entries for other page kinds unless you intend to modify their default output formats.
{{< note >}}
The order of the output formats in the arrays above is important. The first element will be the _primary output format_ for that page kind, and in most cases that should be `html` as shown in the default configuration.
The primary output format for a given page kind determines the value returned by the [`Permalink`] and [`RelPermalink`] methods on a `Page` object.
See the [link to output formats] section for details.
[`Permalink`]: /methods/page/permalink/
[`RelPermalink`]: /methods/page/relpermalink/
[link to output formats]: configuration/output-formats/#link-to-output-formats
{{< /note >}}
> [!note]
> The order of the output formats in the arrays above is important. The first element will be the _primary output format_ for that page kind, and in most cases that should be `html` as shown in the default configuration.
>
> The primary output format for a given page kind determines the value returned by the [`Permalink`] and [`RelPermalink`] methods on a `Page` object.
>
> See the [link to output formats] section for details.
## Outputs per page
@@ -49,3 +42,8 @@ outputs = ['json']
{{< /code-toggle >}}
In its default configuration, Hugo will render both the `html` and `json` output formats for this page. The `outputs` field appends to, rather than replaces, the site's configured outputs.
[`Permalink`]: /methods/page/permalink/
[`RelPermalink`]: /methods/page/relpermalink/
[configure output formats]: /configuration/output-formats/
[link to output formats]: configuration/output-formats/#link-to-output-formats
+2 -3
View File
@@ -27,9 +27,8 @@ To reverse the meaning of _next_ and _previous_:
nextPrevSortOrder = 'asc'
{{< /code-toggle >}}
{{< note >}}
These settings do not apply to the [`Next`] or [`Prev`] methods on a `Pages` object.
> [!note]
> These settings do not apply to the [`Next`] or [`Prev`] methods on a `Pages` object.
[`Next`]: /methods/pages/next
[`Prev`]: /methods/pages/next
{{< /note >}}
+4 -5
View File
@@ -12,11 +12,8 @@ This is the default configuration:
Define a URL pattern for each top-level section. Each URL pattern can target a given language and/or page kind.
{{< note >}}
The [`url`] front matter field overrides any matching permalink pattern.
[`url`]: /content-management/front-matter/#url
{{< /note >}}
> [!note]
> The [`url`] front matter field overrides any matching permalink pattern.
## Monolingual example
@@ -161,3 +158,5 @@ public/
Use these tokens when defining a URL pattern.
{{% include "/_common/permalink-tokens.md" %}}
[`url`]: /content-management/front-matter/#url
+2 -3
View File
@@ -26,9 +26,8 @@ Some of these templates include settings to enhance privacy.
## Configuration
{{< note >}}
These settings affect the behavior of some of Hugo's embedded templates. These settings may or may not affect the behavior of templates provided by third parties in their modules or themes.
{{< /note >}}
> [!note]
> These settings affect the behavior of some of Hugo's embedded templates. These settings may or may not affect the behavior of templates provided by third parties in their modules or themes.
These are the default privacy settings for Hugo's embedded templates:
+6 -8
View File
@@ -6,11 +6,8 @@ categories: []
keywords: []
---
{{< note >}}
To understand Hugo's related content identification, please refer to the [related content] page.
[related content]: /content-management/related-content/
{{< /note >}}
> [!note]
> To understand Hugo's related content identification, please refer to the [related content] page.
Hugo provides a sensible default configuration for identifying related content, but you can customize it in your site configuration, either globally or per language.
@@ -20,9 +17,8 @@ This is the default configuration:
{{< code-toggle config=related />}}
{{< note >}}
Adding a `related` section to your site configuration requires you to provide a full configuration. You cannot override individual default values without specifying all related settings.
{{< /note >}}
> [!note]
> Adding a `related` section to your site configuration requires you to provide a full configuration. You cannot override individual default values without specifying all related settings.
## Top-level options
@@ -111,3 +107,5 @@ Then render a list of 5 related reviews with a partial template like this:
</ul>
{{ end }}
```
[related content]: /content-management/related-content/
+5 -7
View File
@@ -33,13 +33,8 @@ http.mediaTypes
http.urls
: (`[]string`) A slice of regular expressions matching the URLs that the `resources.GetRemote` function is allowed to access.
[inline shortcodes]: /content-management/shortcodes/#inline
[`os.Getenv`]: /functions/os/getenv
[`resources.GetRemote`]: /functions/resources/getremote
{{< note >}}
Setting an allow list to the string `none` will completely disable the associated feature.
{{< /note >}}
> [!note]
> Setting an allow list to the string `none` will completely disable the associated feature.
You can also override the site configuration with environment variables. For example, to block `resources.GetRemote` from accessing any URL:
@@ -49,4 +44,7 @@ export HUGO_SECURITY_HTTP_URLS=none
Learn more about [using environment variables] to configure your site.
[`os.Getenv`]: /functions/os/getenv
[`resources.GetRemote`]: /functions/resources/getremote
[inline shortcodes]: /content-management/shortcodes/#inline
[using environment variables]: /configuration/introduction/#environment-variables
+3 -5
View File
@@ -8,9 +8,8 @@ keywords: []
{{< new-in 0.124.0 />}}
{{< note >}}
The `segments` configuration applies only to segmented rendering. While it controls when content is rendered, it doesn't restrict access to Hugo's complete object graph (sites and pages), which remains fully available.
{{< /note >}}
> [!note]
> The `segments` configuration applies only to segmented rendering. While it controls when content is rendered, it doesn't restrict access to Hugo's complete object graph (sites and pages), which remains fully available.
Segmented rendering offers several advantages:
@@ -43,8 +42,6 @@ output
path
: (`string`) A [glob](g) pattern matching the page's [logical path](g). For example: `{/books,/books/**}`.
[page language]: /methods/page/language/
## Example
Place broad filters, such as those for language or output format, in the excludes section. For example:
@@ -77,3 +74,4 @@ hugo --renderSegments segment1,segment2
```
[`renderSegments`]: /configuration/all/#rendersegments
[page language]: /methods/page/language/
+10 -14
View File
@@ -41,18 +41,8 @@ render
- `link`: Do not render the page to disk, but assign `Permalink` and `RelPermalink` values.
- `never`: Never render the page to disk, and exclude it from all page collections.
[page bundles]: /content-management/page-bundles/
[page resources]: /content-management/page-resources/
[`Permalink`]: /methods/resource/permalink/
[`RelPermalink`]: /methods/resource/relpermalink/
[`Publish`]: /methods/resource/publish/
{{< note >}}
Any page, regardless of its build options, will always be available by using the [`.Page.GetPage`] or [`.Site.GetPage`] method.
[`.Page.GetPage`]: /methods/page/getpage/
[`.Site.GetPage`]: /methods/site/getpage/
{{< /note >}}
> [!note]
> Any page, regardless of its build options, will always be available by using the [`.Page.GetPage`] or [`.Site.GetPage`] method.
## Example -- headless page
@@ -107,8 +97,6 @@ In the example above, note that:
Create a unpublished section whose content and resources can be included in other pages.
[branch bundle]: /content-management/page-bundles/
```text
content/
├── headless/
@@ -305,3 +293,11 @@ public/
│ └── index.html
└── index.html
```
[`.Page.GetPage`]: /methods/page/getpage/
[`.Site.GetPage`]: /methods/site/getpage/
[`Permalink`]: /methods/resource/permalink/
[`Publish`]: /methods/resource/publish/
[`RelPermalink`]: /methods/resource/relpermalink/
[page bundles]: /content-management/page-bundles/
[page resources]: /content-management/page-resources/
@@ -85,9 +85,8 @@ Returns the `Site` to which the pages will be added.
{{ .Site.Title }}
```
{{< note >}}
Note that the `Site` returned isn't fully built when invoked from the content adapters; if you try to call methods that depends on pages, e.g. `.Site.Pages`, you will get an error saying "this method cannot be called before the site is fully initialized".
{{< /note >}}
> [!note]
> Note that the `Site` returned isn't fully built when invoked from the content adapters; if you try to call methods that depends on pages, e.g. `.Site.Pages`, you will get an error saying "this method cannot be called before the site is fully initialized".
### Store
@@ -135,11 +134,10 @@ Key|Description|Required
`path`|The page's [logical path](g) relative to the content adapter. Do not include a leading slash or file extension.|:heavy_check_mark:
`title`|The page title.|&nbsp;
{{< note >}}
While `path` is the only required field, we recommend setting `title` as well.
When setting the `path`, Hugo transforms the given string to a logical path. For example, setting `path` to `A B C` produces a logical path of `/section/a-b-c`.
{{< /note >}}
> [!note]
> While `path` is the only required field, we recommend setting `title` as well.
>
> When setting the `path`, Hugo transforms the given string to a logical path. For example, setting `path` to `A B C` produces a logical path of `/section/a-b-c`.
## Resource map
@@ -154,11 +152,10 @@ Key|Description|Required
`path`|The resources's [logical path](g) relative to the content adapter. Do not include a leading slash.|:heavy_check_mark:
`title`|The resource title.|&nbsp;
{{< note >}}
If the `content.value` is a string Hugo creates a new resource. If the `content.value` is a resource, Hugo obtains the value from the existing resource.
When setting the `path`, Hugo transforms the given string to a logical path. For example, setting `path` to `A B C/cover.jpg` produces a logical path of `/section/a-b-c/cover.jpg`.
{{< /note >}}
> [!note]
> If the `content.value` is a string Hugo creates a new resource. If the `content.value` is a resource, Hugo obtains the value from the existing resource.
>
> When setting the `path`, Hugo transforms the given string to a logical path. For example, setting `path` to `A B C/cover.jpg` produces a logical path of `/section/a-b-c/cover.jpg`.
## Example
@@ -16,9 +16,8 @@ The `data` directory in the root of your project may contain one or more data fi
Hugo also merges data directories from themes and modules into this single data structure, where the `data` directory in the root of your project takes precedence.
{{< note >}}
Hugo reads the combined data structure into memory and keeps it there for the entire build. For data that is infrequently accessed, use global or page resources instead.
{{< /note >}}
> [!note]
> Hugo reads the combined data structure into memory and keeps it there for the entire build. For data that is infrequently accessed, use global or page resources instead.
Theme and module authors may wish to namespace their data files to prevent collisions. For example:
@@ -29,14 +28,11 @@ project/
└── foo.json
```
{{< note >}}
Do not place CSV files in the `data` directory. Access CSV files as page, global, or remote resources.
{{< /note >}}
> [!note]
> Do not place CSV files in the `data` directory. Access CSV files as page, global, or remote resources.
See the documentation for the [`Data`] method on a `Site` object for details and examples.
[`Data`]: /methods/site/data/
## Global resources
Use the `resources.Get` and `transform.Unmarshal` functions to access data files that exist as global resources.
@@ -111,4 +107,5 @@ Felix|cat|Malicious|7
Use [content adapters] to create new content.
[`Data`]: /methods/site/data/
[content adapters]: /content-management/content-adapters/
+4 -5
View File
@@ -9,9 +9,6 @@ keywords: []
Hugo natively supports [GoAT] diagrams with an [embedded code block render hook]. This means that this code block:
[GoAT]: https://github.com/bep/goat
[embedded code block render hook]: {{% eturl render-codeblock-goat %}}
````txt
```goat
. . . .--- 1 .-- 1 / 1
@@ -42,8 +39,6 @@ Will be rendered as:
Hugo does not provide a built-in template for Mermaid diagrams. Create your own using a [code block render hook]:
[code block render hook]: /render-hooks/code-blocks/
```go-html-template {file="layouts/_default/_markup/render-codeblock-mermaid.html" copy=true}
<pre class="mermaid">
{{ .Inner | htmlEscape | safeHTML }}
@@ -259,3 +254,7 @@ Created from <https://arthursonzogni.com/Diagon/#Tree>
│LITERAL = """" character { character } """" .│
└────────────────────────────────────────────────┘
```
[code block render hook]: /render-hooks/code-blocks/
[embedded code block render hook]: {{% eturl render-codeblock-goat %}}
[GoAT]: https://github.com/bep/goat
+1 -1
View File
@@ -58,7 +58,7 @@ Hugo provides custom Markdown features including:
[Markdown]: https://daringfireball.net/projects/markdown/
[Mathematics]: /content-management/mathematics/
[Render hooks]: /render-hooks/introduction/
[configure goldmark]:/configuration/markup/#goldmark
[configure goldmark]: /configuration/markup/#goldmark
### HTML
+11 -13
View File
@@ -39,11 +39,10 @@ Front matter fields may be [boolean](g), [integer](g), [float](g), [string](g),
The most common front matter fields are `date`, `draft`, `title`, and `weight`, but you can specify metadata using any of fields below.
{{< note >}}
The field names below are reserved. For example, you cannot create a custom field named `type`. Create custom fields under the `params` key. See the [parameters] section for details.
> [!note]
> The field names below are reserved. For example, you cannot create a custom field named `type`. Create custom fields under the `params` key. See the [parameters] section for details.
[parameters]: #parameters
{{< /note >}}
aliases
: (`string array`) An array of one or more aliases, where each alias is a relative URL that will redirect the browser to the current location. Access these values from a template using the [`Aliases`] method on a `Page` object. See the [aliases] section for details.
@@ -205,11 +204,6 @@ Parameter|Data type|Used by these embedded templates
The embedded templates will skip a parameter if not provided in front matter, but will throw an error if the data type is unexpected.
[`opengraph.html`]: {{% eturl opengraph %}}
[`schema.html`]: {{% eturl schema %}}
[`twitter_cards.html`]: {{% eturl twitter_cards %}}
[embedded templates]: /templates/embedded/
## Taxonomies
Classify content by adding taxonomy terms to front matter. For example, with this site configuration:
@@ -320,11 +314,10 @@ path = '{/films/**}'
kind = 'page'
{{< /code-toggle >}}
{{< note >}}
For multilingual sites, defining cascade values in your site configuration is often more efficient. This avoids repeating the same cascade values on the home, section, taxonomy, or term page for each language. See&nbsp;[details](/configuration/cascade/).
If you choose to define cascade values in front matter for a multilingual site, you must create a corresponding home, section, taxonomy, or term page for every language.
{{< /note >}}
> [!note]
> For multilingual sites, defining cascade values in your site configuration is often more efficient. This avoids repeating the same cascade values on the home, section, taxonomy, or term page for each language. See&nbsp;[details](/configuration/cascade/).
>
> If you choose to define cascade values in front matter for a multilingual site, you must create a corresponding home, section, taxonomy, or term page for every language.
## Emacs Org Mode
@@ -362,3 +355,8 @@ To override the default time zone, set the [`timeZone`](/configuration/all/#time
1. The time zone offset in the date/time string
1. The time zone specified in your site configuration
1. The `Etc/UTC` time zone
[`opengraph.html`]: {{% eturl opengraph %}}
[`schema.html`]: {{% eturl schema %}}
[`twitter_cards.html`]: {{% eturl twitter_cards %}}
[embedded templates]: /templates/embedded/
@@ -100,17 +100,15 @@ Example 4: Skips rendering if there's problem accessing a remote resource.
The `image` resource implements the [`Process`], [`Resize`], [`Fit`], [`Fill`], [`Crop`], [`Filter`], [`Colors`] and [`Exif`] methods.
{{< note >}}
Metadata (EXIF, IPTC, XMP, etc.) is not preserved during image transformation. Use the `Exif` method with the _original_ image to extract EXIF metadata from JPEG, PNG, TIFF, and WebP images.
{{< /note >}}
> [!note]
> Metadata (EXIF, IPTC, XMP, etc.) is not preserved during image transformation. Use the `Exif` method with the _original_ image to extract EXIF metadata from JPEG, PNG, TIFF, and WebP images.
### Process
{{< new-in 0.119.0 />}}
{{< note >}}
The `Process` method is also available as a filter, which is more effective if you need to apply multiple filters to an image. See [Process filter](/functions/images/process).
{{< /note >}}
> [!note]
> The `Process` method is also available as a filter, which is more effective if you need to apply multiple filters to an image. See [Process filter](/functions/images/process).
Process processes the image with the given specification. The specification can contain an optional action, one of `resize`, `crop`, `fit` or `fill`. This means that you can use this method instead of [`Resize`], [`Fit`], [`Fill`], or [`Crop`].
@@ -248,8 +246,6 @@ You may also access EXIF fields individually, using the [`lang.FormatNumber`] fu
Date
: (`time.Time`) Returns the image creation date/time. Format with the [`time.Format`]function.
[time.Format]: /functions/time/format/
Lat
: (`float64`) Returns the GPS latitude in degrees.
@@ -344,8 +340,6 @@ The default value is 75. You may override the default value in the [site configu
Applicable to WebP images, this option corresponds to a set of predefined encoding parameters, and is equivalent to the `-preset` flag for the [`cwebp`] encoder.
[`cwebp`]: https://developers.google.com/speed/webp/docs/cwebp
Value|Example
:--|:--
`drawing`|Hand or line drawing with high-contrast details
@@ -434,20 +428,20 @@ hugo --gc
```
[`anchor`]: /content-management/image-processing#anchor
[mounted]: /configuration/module/#mounts
[page bundle]: /content-management/page-bundles/
[`lang.FormatNumber`]: /functions/lang/formatnumber/
[filters]: /functions/images/filter/#image-filters
[github.com/disintegration/imaging]: https://github.com/disintegration/imaging#image-resizing
[Smartcrop]: https://github.com/muesli/smartcrop#smartcrop
[Exif]: https://en.wikipedia.org/wiki/Exif
[`Process`]: #process
[`Colors`]: #colors
[`Crop`]: #crop
[`cwebp`]: https://developers.google.com/speed/webp/docs/cwebp
[`Exif`]: #exif
[`Fill`]: #fill
[`Filter`]: #filter
[`Fit`]: #fit
[`lang.FormatNumber`]: /functions/lang/formatnumber/
[`Process`]: #process
[`Resize`]: #resize
[site configuration]: /configuration/imaging/
[`time.Format`]: /functions/time/format/
[`with`]: /functions/go-template/with/
[EXIF]: https://en.wikipedia.org/wiki/Exif
[filters]: /functions/images/filter/#image-filters
[github.com/disintegration/imaging]: https://github.com/disintegration/imaging#image-resizing
[site configuration]: /configuration/imaging/
[Smartcrop]: https://github.com/muesli/smartcrop#smartcrop
+16 -22
View File
@@ -36,13 +36,10 @@ Equations and expressions can be displayed inline with other text, or as standal
Whether an equation or expression appears inline, or as a block, depends on the delimiters that surround the mathematical markup. Delimiters are defined in pairs, where each pair consists of an opening and closing delimiter. The opening and closing delimiters may be the same, or different.
{{< note >}}
You can configure Hugo to render mathematical markup on the client side using the MathJax or KaTeX display engine, or you can render the markup with the [`transform.ToMath`] function while building your site.
The first approach is described below.
[`transform.ToMath`]: /functions/transform/tomath/
{{< /note >}}
> [!note]
> You can configure Hugo to render mathematical markup on the client side using the MathJax or KaTeX display engine, or you can render the markup with the [`transform.ToMath`] function while building your site.
>
> The first approach is described below.
## Setup
@@ -66,11 +63,10 @@ math = true
The configuration above enables mathematical rendering on every page unless you set the `math` parameter to `false` in front matter. To enable mathematical rendering as needed, set the `math` parameter to `false` in your site configuration, and set the `math` parameter to `true` in front matter. Use this parameter in your base template as shown in [Step 3].
{{< note >}}
The configuration above precludes the use of the `$...$` delimiter pair for inline equations. Although you can add this delimiter pair to the configuration and JavaScript, you will need to double-escape the `$` symbol when used outside of math contexts to avoid unintended formatting.
See the [inline delimiters](#inline-delimiters) section for details.
{{< /note >}}
> [!note]
> The configuration above precludes the use of the `$...$` delimiter pair for inline equations. Although you can add this delimiter pair to the configuration and JavaScript, you will need to double-escape the `$` symbol when used outside of math contexts to avoid unintended formatting.
>
> See the [inline delimiters](#inline-delimiters) section for details.
To disable passthrough of inline snippets, omit the `inline` key from the configuration:
@@ -171,19 +167,17 @@ If you add the `$...$` delimiter pair to your configuration and JavaScript, you
A \\$5 bill _saved_ is a \\$5 bill _earned_.
```
{{< note >}}
If you use the `$...$` delimiter pair for inline equations, and occasionally use the&nbsp;`$`&nbsp;symbol outside of math contexts, you must use MathJax instead of KaTeX to avoid unintended formatting caused by [this KaTeX limitation](https://github.com/KaTeX/KaTeX/issues/437).
{{< /note >}}
> [!note]
> If you use the `$...$` delimiter pair for inline equations, and occasionally use the&nbsp;`$`&nbsp;symbol outside of math contexts, you must use MathJax instead of KaTeX to avoid unintended formatting caused by [this KaTeX limitation](https://github.com/KaTeX/KaTeX/issues/437).
## Engines
MathJax and KaTeX are open-source JavaScript display engines. Both engines are fast, but at the time of this writing MathJax v3.2.2 is slightly faster than KaTeX v0.16.11.
{{< note >}}
If you use the `$...$` delimiter pair for inline equations, and occasionally use the&nbsp;`$`&nbsp;symbol outside of math contexts, you must use MathJax instead of KaTeX to avoid unintended formatting caused by [this KaTeX limitation](https://github.com/KaTeX/KaTeX/issues/437).
See the [inline delimiters](#inline-delimiters) section for details.
{{< /note >}}
> [!note]
> If you use the `$...$` delimiter pair for inline equations, and occasionally use the&nbsp;`$`&nbsp;symbol outside of math contexts, you must use MathJax instead of KaTeX to avoid unintended formatting caused by [this KaTeX limitation](https://github.com/KaTeX/KaTeX/issues/437).
>
>See the [inline delimiters](#inline-delimiters) section for details.
To use KaTeX instead of MathJax, replace the partial template from [Step 2] with this:
@@ -235,10 +229,10 @@ $$C_p[\ce{H2O(l)}] = \pu{75.3 J // mol K}$$
As shown in [Step 2] above, MathJax supports chemical equations without additional configuration. To add chemistry support to KaTeX, enable the mhchem extension as described in the KaTeX [documentation](https://katex.org/docs/libs).
[`transform.ToMath`]: /functions/transform/tomath/
[KaTeX]: https://katex.org/
[LaTeX]: https://www.latex-project.org/
[MathJax]: https://www.mathjax.org/
[Step 1]: #step-1
[passthrough extension]: /configuration/markup/#passthrough
[Step 2]: #step-2
[Step 3]: #step-3
[passthrough extension]: /configuration/markup/#passthrough
+4 -7
View File
@@ -22,9 +22,8 @@ There are three ways to define menu entries:
1. In front matter
1. In site configuration
{{< note >}}
Although you can use these methods in combination when defining a menu, the menu will be easier to conceptualize and maintain if you use one method throughout the site.
{{< /note >}}
> [!note]
> Although you can use these methods in combination when defining a menu, the menu will be easier to conceptualize and maintain if you use one method throughout the site.
## Define automatically
@@ -56,9 +55,8 @@ menus = ['main','footer']
Access the entry with `site.Menus.main` and `site.Menus.footer` in your templates. See [menu templates] for details.
{{< note >}}
The configuration key in the examples above is `menus`. The `menu` (singular) configuration key is an alias for `menus`.
{{< /note >}}
> [!note]
> The configuration key in the examples above is `menus`. The `menu` (singular) configuration key is an alias for `menus`.
### Properties
@@ -94,7 +92,6 @@ Hugo provides two methods to localize your menu entries. See [multilingual].
See [menu templates].
[localize]: /content-management/multilingual/#menus
[menu templates]: /templates/menu/
[multilingual]: /content-management/multilingual/#menus
[template]: /templates/menu/
+17 -28
View File
@@ -29,9 +29,8 @@ Their language is __assigned__ according to the language code added as a __suffi
By having the same **path and base file name**, the content pieces are __linked__ together as translated pages.
{{< note >}}
If a file has no language code, it will be assigned the default language.
{{< /note >}}
> [!note]
> If a file has no language code, it will be assigned the default language.
### Translation by content directory
@@ -88,9 +87,6 @@ To localize URLs:
- For a regular page, set either [`slug`] or [`url`] in front matter
- For a section page, set [`url`] in front matter
[`slug`]: /content-management/urls/#slug
[`url`]: /content-management/urls/#url
For example, a French translation can have its own localized slug.
{{< code-toggle file=content/about.fr.md fm=true >}}
@@ -111,9 +107,8 @@ If, across the linked bundles, two or more files share the same basename, only o
- File from current language bundle, if present.
- First file found across bundles by order of language `Weight`.
{{< note >}}
Page Bundle resources follow the same language assignment logic as content files, both by file name (`image.jpg`, `image.fr.jpg`) and by directory (`english/about/header.jpg`, `french/about/header.jpg`).
{{< /note >}}
> [!note]
> Page Bundle resources follow the same language assignment logic as content files, both by file name (`image.jpg`, `image.fr.jpg`) and by directory (`english/about/header.jpg`, `french/about/header.jpg`).
## Reference translated content
@@ -152,8 +147,6 @@ The above also uses the [`i18n` function][i18func] described in the next section
See the [`lang.Translate`] template function.
[`lang.Translate`]: /functions/lang/translate
## Localization
The following localization examples assume your site's primary language is English, with translations to French and German.
@@ -335,8 +328,6 @@ pageRef = '/services'
weight = 20
{{< /code-toggle >}}
[configuration directory]: /configuration/introduction/#configuration-directory
### Use translation tables
When rendering the text that appears in menu each entry, the [example menu template] does this:
@@ -374,20 +365,14 @@ products = 'Produkte'
services = 'Leistungen'
{{< / code-toggle >}}
[example menu template]: /templates/menu/#example
[automatically]: /content-management/menus/#define-automatically
[in front matter]: /content-management/menus/#define-in-front-matter
[in site configuration]: /content-management/menus/#define-in-site-configuration
## Missing translations
If a string does not have a translation for the current language, Hugo will use the value from the default language. If no default value is set, an empty string will be shown.
While translating a Hugo website, it can be handy to have a visual indicator of missing translations. The [`enableMissingTranslationPlaceholders` configuration option][config] will flag all untranslated strings with the placeholder `[i18n] identifier`, where `identifier` is the id of the missing translation.
{{< note >}}
Hugo will generate your website with these missing translation placeholders. It might not be suitable for production environments.
{{< /note >}}
> [!note]
> Hugo will generate your website with these missing translation placeholders. It might not be suitable for production environments.
For merging of content from other languages (i.e. missing content translations), see [lang.Merge].
@@ -423,18 +408,22 @@ hugo new content content/en/post/test.md
hugo new content content/de/post/test.md
```
[`abslangurl`]: /functions/urls/abslangurl/
[`absLangURL`]: /functions/urls/abslangurl/
[`lang.Translate`]: /functions/lang/translate
[`relLangURL`]: /functions/urls/rellangurl/
[`slug`]: /content-management/urls/#slug
[`time.Format`]: /functions/time/format/
[`url`]: /content-management/urls/#url
[automatically]: /content-management/menus/#define-automatically
[config]: /configuration/
[go-i18n-source]: https://github.com/nicksnyder/go-i18n
[go-i18n]: https://github.com/nicksnyder/go-i18n
[Hugo Multilingual Part 1: Content translation]: https://regisphilibert.com/blog/2018/08/hugo-multilingual-part-1-managing-content-translation/
[configuration directory]: /configuration/introduction/#configuration-directory
[example menu template]: /templates/menu/#example
[i18func]: /functions/lang/translate/
[in front matter]: /content-management/menus/#define-in-front-matter
[in site configuration]: /content-management/menus/#define-in-site-configuration
[lang.FormatAccounting]: /functions/lang/formataccounting/
[lang.FormatCurrency]: /functions/lang/formatcurrency/
[lang.FormatNumber]: /functions/lang/formatnumber/
[lang.FormatNumberCustom]: /functions/lang/formatnumbercustom/
[lang.FormatPercent]: /functions/lang/formatpercent/
[lang.Merge]: /functions/lang/merge/
[menus]: /content-management/menus/
[`rellangurl`]: /functions/urls/rellangurl/
[`time.Format`]: /functions/time/format/
@@ -67,9 +67,8 @@ The following demonstrates the relationships between your content organization a
`_index.md` has a special role in Hugo. It allows you to add front matter and content to `home`, `section`, `taxonomy`, and `term` pages.
{{< note >}}
**Tip:** You can get a reference to the content and metadata in `_index.md` using the [`.Site.GetPage` function](/methods/page/getpage).
{{< /note >}}
> [!note]
> Access the content and metadata within an `_index.md` file by invoking the `GetPage` method on a `Site` or `Page` object.
You can create one `_index.md` for your home page and one in each of your content sections, taxonomies, and 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:
@@ -147,10 +146,6 @@ A content's `path` is determined by the section's path to the file. The file `pa
The `url` is the entire URL path, defined by the file path and optionally overridden by a `url` value in front matter. See [URL Management](/content-management/urls/#slug) for details.
[config]: /configuration/
[formats]: /content-management/formats/
[front matter]: /content-management/front-matter/
[getpage]: /methods/page/getpage/
[pretty]: /content-management/urls/#appearance
[sections]: /content-management/sections/
[single template]: /templates/types/#single
[urls]: /content-management/urls/
+11 -15
View File
@@ -29,9 +29,8 @@ leaf bundle
branch bundle
: A _branch bundle_ is a directory that contains an&nbsp;`_index.md`&nbsp;file and zero or more resources. Analogous to a physical branch, a branch bundle may have descendants including leaf bundles and other branch bundles. Top-level directories with or without `_index.md`&nbsp;files are also branch bundles. This includes the home page.
{{< note >}}
In the definitions above and the examples below, the extension of the index file depends on the [content format](g). For example, use `index.md` for Markdown content, `index.html` for HTML content, `index.adoc` for AsciiDoc content, etc.
{{< /note >}}
> [!note]
> In the definitions above and the examples below, the extension of the index file depends on the [content format](g). For example, use `index.md` for Markdown content, `index.html` for HTML content, `index.adoc` for AsciiDoc content, etc.
## Comparison
@@ -47,12 +46,6 @@ Page bundle characteristics vary by bundle type.
| Resource location | Adjacent to the index file or in a nested subdirectory | Same as a leaf bundles, but excludes descendant bundles |
| [Resource types](g) | `page`, `image`, `video`, etc. | all but `page` |
[single]: /templates/types/#single
[home]: /templates/types/#home
[section]: /templates/types/#section
[taxonomy]: /templates/types/#taxonomy
[term]: /templates/types/#term
Files with [resource type](g) `page` include content written in Markdown, HTML, AsciiDoc, Pandoc, reStructuredText, and Emacs Org Mode. In a leaf bundle, excluding the index file, these files are only accessible as page resources. In a branch bundle, these files are only accessible as content pages.
## Leaf bundles
@@ -102,9 +95,8 @@ my-other-post
another-leaf-bundle
: This leaf bundle does not contain any page resources.
{{< note >}}
Create leaf bundles at any depth within the `content` directory, but a leaf bundle may not contain another bundle. Leaf bundles do not have descendants.
{{< /note >}}
> [!note]
> Create leaf bundles at any depth within the `content` directory, but a leaf bundle may not contain another bundle. Leaf bundles do not have descendants.
## Branch bundles
@@ -136,9 +128,8 @@ branch-bundle-1
branch-bundle-2
: This branch bundle contains an index file and a leaf bundle.
{{< note >}}
Create branch bundles at any depth within the `content` directory. Branch bundles may have descendants.
{{< /note >}}
> [!note]
> Create branch bundles at any depth within the `content` directory. Branch bundles may have descendants.
## Headless bundles
@@ -146,4 +137,9 @@ Use [build options] in front matter to create an unpublished leaf or branch bund
[`Resources`]: /methods/page/resources/
[build options]: /content-management/build-options/
[home]: /templates/types/#home
[page resources]: /content-management/page-resources/
[section]: /templates/types/#section
[single]: /templates/types/#single
[taxonomy]: /templates/types/#taxonomy
[term]: /templates/types/#term
+25 -32
View File
@@ -42,12 +42,6 @@ Use any of these methods on a `Page` object to capture page resources:
Once you have captured a resource, use any of the applicable [`Resource`] methods to return a value or perform an action.
[`Resource`]: /methods/resource
[`Resources.ByType`]: /methods/page/resources#bytype
[`Resources.GetMatch`]: /methods/page/resources#getmatch
[`Resources.Get`]: /methods/page/resources#get
[`Resources.Match`]: /methods/page/resources#match
The following examples assume this content structure:
```text
@@ -114,16 +108,14 @@ List the titles in the data file, and throw an error if the file does not exist.
The page resources' metadata is managed from the corresponding page's front matter with an array/table parameter named `resources`. You can batch assign values using [wildcards](https://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm).
{{< note >}}
Resources of type `page` get `Title` etc. from their own front matter.
{{< /note >}}
> [!note]
> Resources of type `page` get `Title` etc. from their own front matter.
name
: (`string`) Sets the value returned in `Name`.
{{< note >}}
The methods `Match`, `Get` and `GetMatch` use `Name` to match the resources.
{{< /note >}}
> [!note]
> The methods `Match`, `Get` and `GetMatch` use `Name` to match the resources.
title
: (`string`) Sets the value returned in `Title`
@@ -167,9 +159,8 @@ From the example above:
- All `PDF` files will get a new `Name`. The `name` parameter contains a special placeholder [`:counter`](#the-counter-placeholder-in-name-and-title), so the `Name` will be `pdf-file-1`, `pdf-file-2`, `pdf-file-3`.
- Every docx in the bundle will receive the `word` icon.
{{< note >}}
The order matters; only the first set values of the `title`, `name` and `params` keys will be used. Consecutive parameters will be set only for the ones not already set. In the above example, `.Params.icon` is first set to `"photo"` in `src = "documents/photo_specs.pdf"`. So that would not get overridden to `"pdf"` by the later set `src = "**.pdf"` rule.
{{< /note >}}
> [!note]
> The order matters; only the first set values of the `title`, `name` and `params` keys will be used. Consecutive parameters will be set only for the ones not already set. In the above example, `.Params.icon` is first set to `"photo"` in `src = "documents/photo_specs.pdf"`. So that would not get overridden to `"pdf"` by the later set `src = "**.pdf"` rule.
### The `:counter` placeholder in `name` and `title`
@@ -204,11 +195,8 @@ the `Name` and `Title` will be assigned to the resource files as follows:
By default, with a multilingual single-host site, Hugo does not duplicate shared page resources when building the site.
{{< note >}}
This behavior is limited to Markdown content. Shared page resources for other [content formats] are copied into each language bundle.
[content formats]: /content-management/formats/
{{< /note >}}
> [!note]
> This behavior is limited to Markdown content. Shared page resources for other [content formats] are copied into each language bundle.
Consider this site configuration:
@@ -283,18 +271,12 @@ public/
This approach reduces build times, storage requirements, bandwidth consumption, and deployment times, ultimately reducing cost.
{{< note >}}
To resolve Markdown link and image destinations to the correct location, you must use link and image render hooks that capture the page resource with the [`Resources.Get`] method, and then invoke its [`RelPermalink`] method.
By default, with multilingual single-host sites, Hugo enables its [embedded link render hook] and [embedded image render hook] to resolve Markdown link and image destinations.
You may override the embedded render hooks as needed, provided they capture the resource as described above.
[embedded link render hook]: /render-hooks/links/#default
[embedded image render hook]: /render-hooks/images/#default
[`Resources.Get`]: /methods/page/resources/#get
[`RelPermalink`]: /methods/resource/relpermalink/
{{< /note >}}
> [!note]
> To resolve Markdown link and image destinations to the correct location, you must use link and image render hooks that capture the page resource with the [`Resources.Get`] method, and then invoke its [`RelPermalink`] method.
>
> By default, with multilingual single-host sites, Hugo enables its [embedded link render hook] and [embedded image render hook] to resolve Markdown link and image destinations.
>
> You may override the embedded render hooks as needed, provided they capture the resource as described above.
Although duplicating shared page resources is inefficient, you can enable this feature in your site configuration if desired:
@@ -302,3 +284,14 @@ Although duplicating shared page resources is inefficient, you can enable this f
[markup.goldmark]
duplicateResourceFiles = true
{{< /code-toggle >}}
[`RelPermalink`]: /methods/resource/relpermalink/
[`Resource`]: /methods/resource
[`Resources.ByType`]: /methods/page/resources#bytype
[`Resources.Get`]: /methods/page/resources#get
[`Resources.Get`]: /methods/page/resources/#get
[`Resources.GetMatch`]: /methods/page/resources#getmatch
[`Resources.Match`]: /methods/page/resources#match
[content formats]: /content-management/formats/
[embedded image render hook]: /render-hooks/images/#default
[embedded link render hook]: /render-hooks/links/#default
@@ -37,8 +37,6 @@ namedSlices
fragments
: (`slice`) A list of special keywords that is used for indices configured as type "fragments". This will match the [fragment](g) identifiers of the documents.
[`keyVals`]: /functions/collections/keyvals/
A fictional example using all of the above options:
```go-html-template
@@ -51,9 +49,8 @@ A fictional example using all of the above options:
}}
```
{{< note >}}
We improved and simplified this feature in Hugo 0.111.0. Before this we had 3 different methods: `Related`, `RelatedTo` and `RelatedIndices`. Now we have only one method: `Related`. The old methods are still available but deprecated. Also see [this blog article](https://regisphilibert.com/blog/2018/04/hugo-optmized-relashionships-with-related-content/) for a great explanation of more advanced usage of this feature.
{{< /note >}}
> [!note]
> We improved and simplified this feature in Hugo 0.111.0. Before this we had 3 different methods: `Related`, `RelatedTo` and `RelatedIndices`. Now we have only one method: `Related`. The old methods are still available but deprecated. Also see [this blog article](https://regisphilibert.com/blog/2018/04/hugo-optmized-relashionships-with-related-content/) for a great explanation of more advanced usage of this feature.
## Index content headings
@@ -101,3 +98,5 @@ weight = 80
## Configuration
See [configure related content](/configuration/related-content/).
[`keyVals`]: /functions/collections/keyvals/
+3 -19
View File
@@ -9,13 +9,7 @@ aliases: [/content/sections/]
## Overview
A section is a top-level content directory, or any content directory with an&nbsp;`_index.md`&nbsp;file. A content directory with an&nbsp;`_index.md`&nbsp;file is also known as a [branch bundle](g). Section templates receive one or more page [collections](g) in [context](g).
{{< note >}}
Although top-level directories without `_index.md`&nbsp;files are sections, we recommend creating `_index.md`&nbsp;files in _all_ sections.
{{< /note >}}
A typical site consists of one or more sections. For example:
{{% glossary-term "section" %}}
```text
content/
@@ -72,9 +66,6 @@ With the file structure from the [example above](#overview):
1. The list page for the products section, by default, includes product-1 and product-2, but not their descendant pages. To include descendant pages, use the `RegularPagesRecursive` method instead of the `Pages` method in the list template.
1. All directories in the products section have list pages; each directory is a section.
[`Pages`]: /methods/page/pages/
[`RegularPagesRecursive`]: /methods/page/regularpagesrecursive/
## Template selection
Hugo has a defined [lookup order] to determine which template to use when rendering a page. The [lookup rules] consider the top-level section name; subsection names are not considered when selecting a template.
@@ -95,9 +86,6 @@ Content directory|Single template
If you need to use a different template for a subsection, specify `type` and/or `layout` in front matter.
[lookup rules]: /templates/lookup-order/#lookup-rules
[lookup order]: /templates/lookup-order/
## Ancestors and descendants
A section has one or more ancestors (including the home page), and zero or more descendants. With the file structure from the [example above](#overview):
@@ -147,9 +135,5 @@ Hugo renders this, where each breadcrumb is a link to the corresponding page:
Home » Products » Product 1 » Benefits » Benefit 1
```
[archetype]: /content-management/archetypes/
[content type]: /content-management/types/
[directory structure]: /getting-started/directory-structure/
[section templates]: /templates/types/#section
[leaf bundles]: /content-management/page-bundles/#leaf-bundles
[branch bundles]: /content-management/page-bundles/#branch-bundles
[lookup order]: /templates/lookup-order/
[lookup rules]: /templates/lookup-order/#lookup-rules
+10 -17
View File
@@ -36,8 +36,6 @@ Then call the shortcode from within markup:
Learn more about creating shortcodes in the [shortcode templates] section.
[shortcode templates]: /templates/shortcode/
## Inline
An inline shortcode is a shortcode template defined within content.
@@ -55,8 +53,6 @@ For more information see [configure security](/configuration/security).
The following example demonstrates an inline shortcode, `date.inline`, that accepts a single positional argument: a date/time [layout string].
[layout string]: /functions/time/format/#layout-string
```text {file="content/example.md"}
Today is
{{</* date.inline ":date_medium" */>}}
@@ -75,11 +71,8 @@ In the example above, the inline shortcode is executed twice: once upon definiti
Inline shortcodes process their inner content within the same context as regular shortcode templates, allowing you to use any available [shortcode method].
[shortcode method]: /templates/shortcode/#methods
{{< note >}}
You cannot [nest](#nesting) inline shortcodes.
{{< /note >}}
> [!note]
> You cannot [nest](#nesting) inline shortcodes.
Learn more about creating shortcodes in the [shortcode templates] section.
@@ -117,10 +110,6 @@ Or use the self-closing syntax with a trailing slash to pass the text as an argu
{{</* qr text=https://gohugo.io /*/>}}
```
[`details`]: /shortcodes/details
[`instagram`]: /shortcodes/instagram
[`qr`]: /shortcodes/qr
Refer to each shortcode's documentation for specific usage instructions and available arguments.
### Arguments
@@ -129,8 +118,6 @@ Shortcode arguments can be either _named_ or _positional_.
Named arguments are passed as case-sensitive key-value pairs, as seen in this example with the embedded [`figure`] shortcode. The `src` argument, for instance, is required.
[`figure`]: /shortcodes/figure
```text
{{</* figure src=/images/kitten.jpg */>}}
```
@@ -188,8 +175,6 @@ Standard|`{{</* foo */>}} ## Section 2 {{</* /foo */>}}`
Hugo processes the shortcode before the page content is rendered by the Markdown renderer. This means, for instance, that Markdown headings inside a Markdown-notation shortcode will be included when invoking the [`TableOfContents`] method on the `Page` object.
[`TableOfContents`]: /methods/page/tableofcontents/
#### Standard notation
With standard notation, Hugo processes the shortcode separately, merging the output into the page content after Markdown rendering. This means, for instance, that Markdown headings inside a standard-notation shortcode will be excluded when invoking the `TableOfContents` method on the `Page` object.
@@ -234,4 +219,12 @@ Shortcodes (excluding [inline](#inline) shortcodes) can be nested, creating pare
The [shortcode templates][nesting] section provides a detailed explanation and examples.
[`details`]: /shortcodes/details
[`figure`]: /shortcodes/figure
[`instagram`]: /shortcodes/instagram
[`qr`]: /shortcodes/qr
[`TableOfContents`]: /methods/page/tableofcontents/
[layout string]: /functions/time/format/#layout-string
[nesting]: /templates/shortcode/#nesting
[shortcode method]: /templates/shortcode/#methods
[shortcode templates]: /templates/shortcode/
+13 -18
View File
@@ -37,14 +37,10 @@ https://example.org/posts/my-first-post/
Set the `url` in front matter to override the entire path. Use this with either regular pages or section pages.
{{< note >}}
Hugo does not sanitize the `url` front matter field, allowing you to generate:
- File paths that contain characters reserved by the operating system. For example, file paths on Windows may not contain any of these [reserved characters]. Hugo throws an error if a file path includes a character reserved by the current operating system.
- URLs that contain disallowed characters. For example, the less than sign (`<`) is not allowed in a URL.
[reserved characters]: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
{{< /note >}}
> [!note]
> Hugo does not sanitize the `url` front matter field, allowing you to generate:
> - File paths that contain characters reserved by the operating system. For example, file paths on Windows may not contain any of these [reserved characters]. Hugo throws an error if a file path includes a character reserved by the current operating system.
> - URLs that contain disallowed characters. For example, the less than sign (`<`) is not allowed in a URL.
If you set both `slug` and `url` in front matter, the `url` value takes precedence.
@@ -101,8 +97,6 @@ https://example.org/articles/my-first-article.html
With monolingual sites, `url` values with or without a leading slash are relative to the [`baseURL`]. With multilingual sites, `url` values with a leading slash are relative to the `baseURL`, and `url` values without a leading slash are relative to the `baseURL` plus the language prefix.
[`baseURL`]: /configuration/all/#baseurl
Site type|Front matter `url`|Resulting URL
:--|:--|:--
monolingual|`/about`|`https://example.org/about/`
@@ -142,11 +136,9 @@ Hugo provides two mutually exclusive configuration options to alter URLs _after_
#### Canonical URLs
{{< note >}}
This is a legacy configuration option, superseded by template functions and Markdown render hooks, and will likely be [removed in a future release].
[removed in a future release]: https://github.com/gohugoio/hugo/issues/4733
{{< /note >}}
> [!caution]
> This is a legacy configuration option, superseded by template functions and Markdown render hooks, and will likely be [removed in a future release].
{class="!mt-6"}
If enabled, Hugo performs a search and replace _after_ it renders the page. It searches for site-relative URLs (those with a leading slash) associated with `action`, `href`, `src`, `srcset`, and `url` attributes. It then prepends the `baseURL` to create absolute URLs.
@@ -165,9 +157,9 @@ canonifyURLs = true
#### Relative URLs
{{< note >}}
Do not enable this option unless you are creating a serverless site, navigable via the file system.
{{< /note >}}
> [!caution]
> Do not enable this option unless you are creating a serverless site, navigable via the file system.
{class="!mt-6"}
If enabled, Hugo performs a search and replace _after_ it renders the page. It searches for site-relative URLs (those with a leading slash) associated with `action`, `href`, `src`, `srcset`, and `url` attributes. It then transforms the URL to be relative to the current page.
@@ -267,4 +259,7 @@ Permalink
Page
: The Page data for the page being aliased.
[`baseURL`]: /configuration/all/#baseurl
[removed in a future release]: https://github.com/gohugoio/hugo/issues/4733
[reserved characters]: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
[source code]: {{% eturl alias %}}
+21 -26
View File
@@ -27,16 +27,6 @@ If there is sufficient interest, [create a proposal]. Do not submit a pull reque
For a complete guide to contributing to Hugo, see the [Contribution Guide].
[bugs]: https://github.com/gohugoio/hugo/issues?q=is%3Aopen+is%3Aissue+label%3ABug
[contributing]: CONTRIBUTING.md
[create a proposal]: https://github.com/gohugoio/hugo/issues/new?labels=Proposal%2C+NeedsTriage&template=feature_request.md
[documentation repository]: https://github.com/gohugoio/hugoDocs
[documentation]: /documentation
[forum]: https://discourse.gohugo.io
[issue queue]: https://github.com/gohugoio/hugo/issues
[themes]: https://themes.gohugo.io/
[contribution guide]: https://github.com/gohugoio/hugo/blob/master/CONTRIBUTING.md
## Prerequisites
To build the extended or extended/deploy edition from source you must:
@@ -46,21 +36,13 @@ To build the extended or extended/deploy edition from source you must:
1. Install a C compiler, either [GCC] or [Clang]
1. Update your `PATH` environment variable as described in the [Go documentation]
[Clang]: https://clang.llvm.org/
[GCC]: https://gcc.gnu.org/
[Git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
[Go documentation]: https://go.dev/doc/code#Command
[Go]: https://go.dev/doc/install
{{< note >}}
See these [detailed instructions](https://discourse.gohugo.io/t/41370) to install GCC on Windows.
{{< /note >}}
> [!note]
> See these [detailed instructions](https://discourse.gohugo.io/t/41370) to install GCC on Windows.
## GitHub workflow
{{< note >}}
This section assumes that you have a working knowledge of Go, Git and GitHub, and are comfortable working on the command line.
{{< /note >}}
> [!note]
> This section assumes that you have a working knowledge of Go, Git and GitHub, and are comfortable working on the command line.
Use this workflow to create and submit pull requests.
@@ -157,10 +139,6 @@ Visit the [project repository] and create a pull request (PR).
A project maintainer will review your PR and may request changes. You may delete your branch after the maintainer merges your PR.
[commit message guidelines]: https://github.com/gohugoio/hugo/blob/master/CONTRIBUTING.md#git-commit-message-guidelines
[issues]: https://github.com/gohugoio/hugo/issues
[project repository]: https://github.com/gohugoio/hugo/
## Building from source
You can build, install, and test Hugo at any point in its development history. The examples below build and install the extended edition of Hugo.
@@ -188,3 +166,20 @@ To build and install at a specific commit:
```sh
CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@0851c17
```
[bugs]: https://github.com/gohugoio/hugo/issues?q=is%3Aopen+is%3Aissue+label%3ABug
[Clang]: https://clang.llvm.org/
[commit message guidelines]: https://github.com/gohugoio/hugo/blob/master/CONTRIBUTING.md#git-commit-message-guidelines
[Contribution Guide]: https://github.com/gohugoio/hugo/blob/master/CONTRIBUTING.md
[create a proposal]: https://github.com/gohugoio/hugo/issues/new?labels=Proposal%2C+NeedsTriage&template=feature_request.md
[documentation]: /documentation
[documentation repository]: https://github.com/gohugoio/hugoDocs
[forum]: https://discourse.gohugo.io
[GCC]: https://gcc.gnu.org/
[Git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
[Go]: https://go.dev/doc/install
[Go documentation]: https://go.dev/doc/code#Command
[issue queue]: https://github.com/gohugoio/hugo/issues
[issues]: https://github.com/gohugoio/hugo/issues
[project repository]: https://github.com/gohugoio/hugo/
[themes]: https://themes.gohugo.io/
+55 -34
View File
@@ -19,8 +19,6 @@ We welcome corrections and improvements to the documentation. The documentation
Follow Google's [developer documentation style guide].
[developer documentation style guide]: https://developers.google.com/style
### Markdown
Adhere to these Markdown conventions:
@@ -28,7 +26,7 @@ Adhere to these Markdown conventions:
- Use [ATX] headings (levels 2-4), not [setext] headings.
- Use [fenced code blocks], not [indented code blocks].
- Use hyphens, not asterisks, for unordered [list items].
- Use the [note shortcode](#note) instead of blockquotes or bold text for emphasis.
- Use the [callouts](#callouts) instead bold text for emphasis.
- Do not mix [raw HTML] within Markdown.
- Do not use bold text in place of a heading or description term (`dt`).
- Remove consecutive blank lines.
@@ -99,17 +97,13 @@ Minimize adverbs.
No → Hugo is extremely fast.\
Yes → Hugo is fast.
{{< note >}}
"It's an adverb, Sam. It's a lazy tool of a weak mind." (Outbreak, 1995).
{{< /note >}}
> [!note]
> "It's an adverb, Sam. It's a lazy tool of a weak mind." (Outbreak, 1995).
### Function and method descriptions
Start descriptions in the functions and methods sections with "Returns" or "Reports whether" for boolean values.
[functions]: /functions
[methods]: /methods
### File paths and names
Enclose directory names, file names, and file paths in backticks, except when used in:
@@ -124,15 +118,13 @@ Enclose directory names, file names, and file paths in backticks, except when us
Other best practices:
- Introduce lists with a sentence or phrase, not directly under a heading.
- Avoid bold text; use the [note shortcode](#note) for emphasis.
- Avoid bold text; use [callouts](#callouts) for emphasis.
- Do not put description terms (`dt`) in backticks unless syntactically necessary.
- Do not use Hugo's `ref` or `relref` shortcodes.
- Prioritize current best practices over multiple options or historical information.
- Use short, focused code examples.
- Use [basic english] where possible for a global audience.
[basic english]: https://simple.wikipedia.org/wiki/Basic_English
## Front matter fields
This site uses the front matter fields listed in the table below.
@@ -177,8 +169,6 @@ Seq|Field|Description|Required
When available, the "See also" sidebar displays related pages using Hugo's [related content] feature, based on front matter keywords. We ensure consistent keyword usage by validating them against `data/keywords.yaml` during the build process. If a keyword is not found, you'll be alerted and must either modify the keyword or update the data file. This validation process helps to refine the related content for better results.
[related content]: /content-management/related-content/
If the title in the "See also" sidebar is ambiguous or the same as another page, you can define an alternate title in the front matter:
{{< code-toggle file=hugo >}}
@@ -189,10 +179,9 @@ altTitle = "Whatever you want"
{{< /code-toggle >}}
Use of the alternate title is limited to the "See also" sidebar.
{{< note >}}
Think carefully before setting the `altTitle`. Use it only when absolutely necessary.
{{< /note >}}
> [!note]
> Think carefully before setting the `altTitle`. Use it only when absolutely necessary.
## Code examples
@@ -269,6 +258,50 @@ draft = false
{{</* /code-toggle */>}}
```
## Callouts
Also known as admonitions, use callouts to visually highlight important information. The type (e.g., NOTE, TIP) is case-insensitive.
```text
> [!NOTE]
> Useful information that users should know, even when skimming content.
```
> [!NOTE]
> Useful information that users should know, even when skimming content.
```text
> [!TIP]
> Helpful advice for doing things better or more easily.
```
> [!TIP]
> Helpful advice for doing things better or more easily.
```text
> [!IMPORTANT]
> Key information users need to know to achieve their goal.
```
> [!IMPORTANT]
> Key information users need to know to achieve their goal.
```text
> [!WARNING]
> Urgent info that needs immediate user attention to avoid problems.
```
> [!WARNING]
> Urgent info that needs immediate user attention to avoid problems.
```text
> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.
```
> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.
## Shortcodes
These shortcodes are commonly used throughout the documentation. Other shortcodes are available for specialized use.
@@ -358,18 +391,6 @@ This is a new feature.
{{</* /new-in */>}}
```
### note
Use the `note` shortcode to call attention to important content:
```text
{{</* note */>}}
Use the [`math.Mod`] function to control...
[`math.Mod`]: /functions/math/mod/
{{</* /note */>}}
```
## New features
Use the [new-in shortcode](#new-in) to indicate a new feature:
@@ -402,9 +423,8 @@ Set the `expiryDate` to two years from the date of deprecation, and add a brief
## GitHub workflow
{{< note >}}
This section assumes that you have a working knowledge of Git and GitHub, and are comfortable working on the command line.
{{< /note >}}
> [!note]
> This section assumes that you have a working knowledge of Git and GitHub, and are comfortable working on the command line.
Use this workflow to create and submit pull requests.
@@ -467,9 +487,9 @@ Visit the [documentation repository] and create a pull request (PR).
A project maintainer will review your PR and may request changes. You may delete your branch after the maintainer merges your PR.
[ATX]: https://spec.commonmark.org/0.30/#atx-headings
[Microsoft Writing Style Guide]: https://learn.microsoft.com/en-us/style-guide/welcome/
[basic english]: https://simple.wikipedia.org/wiki/Basic_English
[code examples]: #code-examples
[basic english]: https://simple.wikipedia.org/wiki/Basic_English
[developer documentation style guide]: https://developers.google.com/style
[documentation repository]: https://github.com/gohugoio/hugoDocs/
[fenced code blocks]: https://spec.commonmark.org/0.30/#fenced-code-blocks
[glossary]: /quick-reference/glossary/
@@ -478,4 +498,5 @@ A project maintainer will review your PR and may request changes. You may delete
[list items]: https://spec.commonmark.org/0.30/#list-items
[project repository]: https://github.com/gohugoio/hugo
[raw HTML]: https://spec.commonmark.org/0.30/#raw-html
[related content]: /content-management/related-content/
[setext]: https://spec.commonmark.org/0.30/#setext-heading
+2 -3
View File
@@ -44,8 +44,7 @@ With a hexadecimal (base 16) input:
{{ int "0x11" }} → 17 (int)
```
{{< note >}}
Values with a leading zero are octal (base 8). When casting a string representation of a decimal (base 10) number, remove leading zeros:
> [!note]
> Values with a leading zero are octal (base 8). When casting a string representation of a decimal (base 10) number, remove leading zeros:
`{{ strings.TrimLeft "0" "0011" | int }} → 11`
{{< /note >}}
+6 -10
View File
@@ -21,11 +21,8 @@ To find the elements within `$c3` that do not exist in `$c1` or `$c2`:
{{ complement $c1 $c2 $c3 }} → [1 2]
```
{{< note >}}
Make your code simpler to understand by using a [chained pipeline]:
[chained pipeline]: https://pkg.go.dev/text/template#hdr-Pipelines
{{< /note >}}
> [!note]
> Make your code simpler to understand by using a [chained pipeline]:
```go-html-template
{{ $c3 | complement $c1 $c2 }} → [1 2]
@@ -52,11 +49,8 @@ To list everything except blog articles (`blog`) and frequently asked questions
{{ end }}
```
{{< note >}}
Although the example above demonstrates the `complement` function, you could use the [`where`] function as well:
[`where`]: /functions/collections/where/
{{< /note >}}
> [!note]
> Although the example above demonstrates the `complement` function, you could use the [`where`] function as well:
```go-html-template
{{ range where site.RegularPages "Type" "not in" (slice "blog" "faqs") }}
@@ -74,4 +68,6 @@ In this example we use the `complement` function to remove [stop words] from a s
{{ delimit $filtered " " }} → The quick brown fox jumps lazy dog
```
[`where`]: /functions/collections/where/
[chained pipeline]: https://pkg.go.dev/text/template#hdr-Pipelines
[stop words]: https://en.wikipedia.org/wiki/Stop_word
+2 -3
View File
@@ -21,9 +21,8 @@ Delimit a slice:
Delimit a map:
{{< note >}}
The `delimit` function sorts maps by key, returning the values.
{{< /note >}}
> [!note]
> The `delimit` function sorts maps by key, returning the values.
```go-html-template
{{ $m := dict "b" 2 "a" 1 "c" 3 }}
+2 -3
View File
@@ -38,6 +38,5 @@ But if the value of `showHeroImage` is `false`, we can't use either `if` or `wit
{{ end }}
```
{{< note >}}
When using the `isset` function you must reference the key using lower case. See the previous example.
{{< /note >}}
> [!note]
> When using the `isset` function you must reference the key using lower case. See the previous example.
+2 -3
View File
@@ -63,6 +63,5 @@ Example 4
{{ $merged.z.a }} → huey
```
{{< note >}}
Regardless of depth, merging only applies to maps. For slices, use [append](/functions/collections/append).
{{< /note >}}
> [!note]
> Regardless of depth, merging only applies to maps. For slices, use [append](/functions/collections/append).
+2 -3
View File
@@ -32,6 +32,5 @@ A contrived example of iterating over a sequence of integers:
{{ $product }} → 24
```
{{< note >}}
The slice created by the `seq` function is limited to 2000 elements.
{{< /note >}}
> [!note]
> The slice created by the `seq` function is limited to 2000 elements.
+6 -8
View File
@@ -61,9 +61,8 @@ firstName = "Jean"
lastName = "Valjean"
{{< /code-toggle >}}
{{< note >}}
When sorting maps, the `KEY` argument must be lowercase.
{{< /note >}}
> [!note]
> When sorting maps, the `KEY` argument must be lowercase.
### Ascending order {#map-ascending-order}
@@ -137,11 +136,8 @@ After sorting:
## Sort a page collection
{{< note >}}
Although you can use the `sort` function to sort a page collection, Hugo provides [sorting and grouping methods] as well.
[sorting and grouping methods]: /methods/pages/
{{< /note >}}
> [!note]
> Although you can use the `sort` function to sort a page collection, Hugo provides [sorting and grouping methods] as well.
In this contrived example, sort the site's regular pages by `.Type` in descending order:
@@ -150,3 +146,5 @@ In this contrived example, sort the site's regular pages by `.Type` in descendin
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
[sorting and grouping methods]: /methods/pages/
+13 -20
View File
@@ -91,9 +91,8 @@ Use any of the following logical operators:
: {{< new-in 0.116.0 />}}
: (`bool`) Reports whether the given field value matches the regular expression specified in `VALUE`. Use the `like` operator to compare `string` values. The `like` operator returns `false` when comparing other data types to the regular expression.
{{< note >}}
The examples below perform comparisons within a page collection, but the same comparisons are applicable to a slice of maps.
{{< /note >}}
> [!note]
> The examples below perform comparisons within a page collection, but the same comparisons are applicable to a slice of maps.
## String comparison
@@ -156,7 +155,7 @@ To return a collection of pages where the "color" page parameter is neither "red
## Intersection comparison
Compare a [`slice`] to a [`slice`], returning collection elements with common values. This is frequently used when comparing taxonomy terms.
Compare a `slice` to a `slice`, returning collection elements with common values. This is frequently used when comparing taxonomy terms.
For example, to return a collection of pages where any of the terms in the "genres" taxonomy are "suspense" or "romance":
@@ -179,9 +178,8 @@ To return a collection of pages where the "author" page parameter begins with ei
{{% include "/_common/functions/regular-expressions.md" %}}
{{< note >}}
Use the `like` operator to compare string values. Comparing other data types will result in an empty collection.
{{< /note >}}
> [!note]
> Use the `like` operator to compare string values. Comparing other data types will result in an empty collection.
## Date comparison
@@ -189,12 +187,6 @@ Use the `like` operator to compare string values. Comparing other data types wil
There are four predefined front matter dates: [`date`], [`publishDate`], [`lastmod`], and [`expiryDate`]. Regardless of the front matter data format (TOML, YAML, or JSON) these are [`time.Time`] values, allowing precise comparisons.
[`date`]: /methods/page/date/
[`publishdate`]: /methods/page/publishdate/
[`lastmod`]: /methods/page/lastmod/
[`expirydate`]: /methods/page/expirydate/
[`time.Time`]: https://pkg.go.dev/time#Time
For example, to return a collection of pages that were created before the current year:
```go-html-template
@@ -206,9 +198,8 @@ For example, to return a collection of pages that were created before the curren
With custom front matter dates, the comparison depends on the front matter data format (TOML, YAML, or JSON).
{{< note >}}
Using TOML for pages with custom front matter dates enables precise date comparisons.
{{< /note >}}
> [!note]
> Using TOML for pages with custom front matter dates enables precise date comparisons.
With TOML, date values are first-class citizens. TOML has a date data type while JSON and YAML do not. If you quote a TOML date, it is a string. If you do not quote a TOML date value, it is [`time.Time`] value, enabling precise comparisons.
@@ -273,8 +264,6 @@ These are equivalent:
Useful for theme authors, avoid hardcoding section names by using the `where` function with the [`MainSections`] method on a `Site` object.
[`MainSections`]: /methods/site/mainsections/
```go-html-template
{{ $pages := where .Site.RegularPages "Section" "in" .Site.MainSections }}
```
@@ -387,8 +376,6 @@ To exclude a page with an undefined field from a boolean _inequality_ test:
1. Create a collection using a nil comparison
1. Subtract the second collection from the first collection using the [`collections.Complement`] function.
[`collections.Complement`]: /functions/collections/complement/
This template:
```go-html-template
@@ -428,3 +415,9 @@ Is rendered to:
<li><a href="/posts/post-1/">Post 2</a></li>
</ul>
```
[`collections.Complement`]: /functions/collections/complement/
[`date`]: /methods/page/date/
[`lastmod`]: /methods/page/lastmod/
[`MainSections`]: /methods/site/mainsections/
[`time.Time`]: https://pkg.go.dev/time#Time
+10 -9
View File
@@ -12,15 +12,14 @@ aliases: [/functions/default]
The `default` function returns the second argument if set, else the first argument.
{{< note >}}
When the second argument is the boolean `false` value, the `default` function returns `false`. All _other_ falsy values are considered unset.
{{% include "/_common/functions/truthy-falsy.md" %}}
To set a default value based on truthiness, use the [`or`] operator instead.
[`or`]: /functions/go-template/or/
{{< /note >}}
> [!note]
> When the second argument is the boolean `false` value, the `default` function returns `false`. All _other_ falsy values are considered unset.
>
> The falsy values are `false`, `0`, any `nil` pointer or interface value, any array, slice, map, or string of length zero, and zero `time.Time` values.
>
> Everything else is truthy.
>
> To set a default value based on truthiness, use the [`or`] operator instead.
The `default` function returns the second argument if set:
@@ -44,3 +43,5 @@ The `default` function returns the first argument if the second argument is not
{{ default 42 slice }} → 42
{{ default 42 <nil> }} → 42
```
[`or`]: /functions/go-template/or/
+7 -7
View File
@@ -22,14 +22,10 @@ params:
Follow the steps below to transform CSS using any of the available [PostCSS plugins].
[postcss plugins]: https://postcss.org/docs/postcss-plugins
### Step 1
Install [Node.js].
[node.js]: https://nodejs.org/en/download
### Step 2
Install the required Node.js packages in the root of your project. For example, to add vendor prefixes to your CSS rules:
@@ -50,9 +46,8 @@ module.exports = {
};
```
{{< note >}}
{{% include "/_common/functions/postcss-windows-warning.md" %}}
{{< /note >}}
> [!note]
> If you are a Windows user, and the path to your project contains a space, you must place the PostCSS configuration within the package.json file. See [this example] and issue [#7333].
### Step 4
@@ -126,3 +121,8 @@ module.exports = {
]
}
```
[#7333]: https://github.com/gohugoio/hugo/issues/7333
[Node.js]: https://nodejs.org/en
[PostCSS plugins]: https://postcss.org/docs/postcss-plugins
[this example]: https://github.com/postcss/postcss-load-config#packagejson
+4 -5
View File
@@ -36,11 +36,10 @@ Access the data with either of the following:
{{ $data := getCSV "," "other-files/" "pets.csv" }}
```
{{< note >}}
When working with local data, the file path is relative to the working directory.
You must not place CSV files in the project's `data` directory.
{{< /note >}}
> [!note]
> When working with local data, the file path is relative to the working directory.
>
> You must not place CSV files in the project's `data` directory.
Access remote data with either of the following:
+2 -3
View File
@@ -36,9 +36,8 @@ Access the data with either of the following:
{{ $data := getJSON "other-files/" "books.json" }}
```
{{< note >}}
When working with local data, the file path is relative to the working directory.
{{< /note >}}
> [!note]
> When working with local data, the file path is relative to the working directory.
Access remote data with either of the following:
+2 -3
View File
@@ -30,6 +30,5 @@ params:
]
```
{{< note >}}
Output from this function may change from one release to the next. Use for debugging only.
{{< /note >}}
> [!note]
> Output from this function may change from one release to the next. Use for debugging only.
+5 -6
View File
@@ -13,9 +13,6 @@ params:
Useful in a [code block render hook], the `diagram.Goat` function converts ASCII art to an SVG diagram, returning a [GoAT] diagram object with the following methods:
[GoAT]: https://github.com/blampe/goat#readme
[code block render hook]: /render-hooks/code-blocks/
Inner
: (`template.HTML`) Returns the SVG child elements without a wrapping `svg` element, allowing you to create your own wrapper.
@@ -30,9 +27,7 @@ Height
## GoAT Diagrams
Hugo natively supports [GoAT](https://github.com/bep/goat) diagrams with an [embedded code block render hook].
[embedded code block render hook]: {{% eturl render-codeblock-goat %}}
Hugo natively supports GoAT diagrams with an [embedded code block render hook].
This Markdown:
@@ -111,3 +106,7 @@ svg.foo {
font-family: "Segoe UI","Noto Sans",Helvetica,Arial,sans-serif
}
```
[code block render hook]: /render-hooks/code-blocks/
[embedded code block render hook]: {{% eturl render-codeblock-goat %}}
[GoAT]: https://github.com/bep/goat
+3 -4
View File
@@ -25,9 +25,8 @@ When a `Page` object is not in context, you can use the global `page` function:
{{ page.Params.foo }}
```
{{< note >}}
Do not use the global `page` function in shortcodes, partials called by shortcodes, or cached partials. See [warnings](#warnings) below.
{{< /note >}}
> [!note]
> Do not use the global `page` function in shortcodes, partials called by shortcodes, or cached partials. See [warnings](#warnings) below.
## Explanation
@@ -97,5 +96,5 @@ When you call the [`Summary`] method, Hugo renders the page content including sh
If Hugo renders the section page before a content page, the cached rendered shortcode will be incorrect. You cannot control the rendering sequence due to concurrency.
[`Summary`]: /methods/page/summary/
[`partialCached`]: /functions/partials/includecached/
[`Summary`]: /methods/page/summary/
+2 -3
View File
@@ -26,6 +26,5 @@ When the `Site` object is in context you can use the `Site` property:
{{ $.Site.Params.foo }}
```
{{< note >}}
To simplify your templates, use the global `site` function regardless of whether the `Site` object is in context.
{{< /note >}}
> [!note]
> To simplify your templates, use the global `site` function regardless of whether the `Site` object is in context.
+6 -9
View File
@@ -54,9 +54,8 @@ Hugo will throw an error:
The error occurs because we are trying to use the `.Title` method on an integer instead of a `Page` object. Within the `range` block, if we want to render the page title, we need to get the context passed into the template.
{{< note >}}
Use the `$` to get the context passed into the template.
{{< /note >}}
> [!note]
> Use the `$` to get the context passed into the template.
This template will render the page title three times:
@@ -66,11 +65,8 @@ This template will render the page title three times:
{{ end }}
```
{{< note >}}
Gaining a thorough understanding of context is critical for anyone writing template code.
{{< /note >}}
[`seq`]: /functions/collections/seq/
> [!note]
> Gaining a thorough understanding of context is critical for anyone writing template code.
## Array or slice of scalars
@@ -188,6 +184,7 @@ Unlike ranging over an array or slice, Hugo sorts by key when ranging over a map
{{% include "/_common/functions/go-template/text-template.md" %}}
[`else`]: /functions/go-template/else/
[`break`]: /functions/go-template/break/
[`continue`]: /functions/go-template/continue/
[`else`]: /functions/go-template/else/
[`seq`]: /functions/collections/seq/
+9 -11
View File
@@ -16,9 +16,8 @@ The returned value may be of any data type including, but not limited to, [`bool
A `return` statement without a value returns an empty string of type `template.HTML`.
{{< note >}}
Unlike `return` statements in other languages, Hugo executes the first occurrence of the `return` statement regardless of its position within logical blocks. See [usage](#usage) notes below.
{{< /note >}}
> [!note]
> Unlike `return` statements in other languages, Hugo executes the first occurrence of the `return` statement regardless of its position within logical blocks. See [usage](#usage) notes below.
## Example
@@ -63,13 +62,10 @@ Hugo renders:
See additional examples in the [partial templates] section.
[partial templates]: /templates/partial/#returning-a-value-from-a-partial
## Usage
{{< note >}}
Unlike `return` statements in other languages, Hugo executes the first occurrence of the `return` statement regardless of its position within logical blocks.
{{< /note >}}
> [!note]
> Unlike `return` statements in other languages, Hugo executes the first occurrence of the `return` statement regardless of its position within logical blocks.
A partial that returns a value must contain only one `return` statement, placed at the end of the template.
@@ -85,9 +81,8 @@ For example:
{{ return $result }}
```
{{< note >}}
The construct below is incorrect; it contains more than one `return` statement.
{{< /note >}}
> [!note]
> The construct below is incorrect; it contains more than one `return` statement.
```go-html-template {file="layouts/partials/do-not-do-this.html"}
{{ if math.ModBool . 2 }}
@@ -96,3 +91,6 @@ The construct below is incorrect; it contains more than one `return` statement.
{{ return "odd" }}
{{ end }}
```
[partial templates]: /templates/partial/#returning-a-value-from-a-partial
[text/template package]: https://pkg.go.dev/text/template
+5 -8
View File
@@ -15,8 +15,6 @@ params:
The `try` statement is a non-standard extension to Go's [text/template] package. It introduces a mechanism for handling errors within templates, mimicking the `try-catch` constructs found in other programming languages.
[text/template]: https://pkg.go.dev/text/template
## Methods
The `TryValue` object encapsulates the result of evaluating the expression, and provides two methods:
@@ -90,8 +88,6 @@ Hugo renders the above to:
Error handling is essential when using the [`resources.GetRemote`] function to capture remote resources such as data or images. When calling this function, if the HTTP request fails, Hugo will fail the build.
[`resources.GetRemote`]: /functions/resources/getremote/
Instead of failing the build, we can catch the error and emit a warning:
```go-html-template
@@ -108,8 +104,9 @@ Instead of failing the build, we can catch the error and emit a warning:
```
In the above, note that the [context](g) within the last conditional block is the `TryValue` object returned by the `try` statement. At this point neither the `Err` nor `Value` methods returned anything, so the current context is not useful. Use the `$` to access the [template context] if needed.
[template context]: /templates/introduction/#template-context
> [!note]
> Hugo does not classify an HTTP response with status code 404 as an error. In this case `resources.GetRemote` returns nil.
{{< note >}}
Hugo does not classify an HTTP response with status code 404 as an error. In this case `resources.GetRemote` returns nil.
{{< /note >}}
[`resources.GetRemote`]: /functions/resources/getremote/
[template context]: /templates/introduction/#template-context
[text/template]: https://pkg.go.dev/text/template
+4 -6
View File
@@ -73,9 +73,8 @@ Hugo will throw an error:
The error occurs because we are trying to use the `.Title` method on an integer instead of a `Page` object. Inside of the `with` block, if we want to render the page title, we need to get the context passed into the template.
{{< note >}}
Use the `$` to get the context passed into the template.
{{< /note >}}
> [!note]
> Use the `$` to get the context passed into the template.
This template will render the page title as desired:
@@ -85,9 +84,8 @@ This template will render the page title as desired:
{{ end }}
```
{{< note >}}
Gaining a thorough understanding of context is critical for anyone writing template code.
{{< /note >}}
> [!note]
> Gaining a thorough understanding of context is critical for anyone writing template code.
{{% include "/_common/functions/go-template/text-template.md" %}}
+2 -3
View File
@@ -22,9 +22,8 @@ Create the filter:
{{% include "/_common/functions/images/apply-image-filter.md" %}}
{{< note >}}
When using with other filters, specify `images.AutoOrient` first.
{{< /note >}}
> [!note]
> When using with other filters, specify `images.AutoOrient` first.
```go-html-template
{{ $filters := slice
+3 -6
View File
@@ -14,8 +14,6 @@ aliases: [/functions/imageconfig]
See [image processing] for an overview of Hugo's image pipeline.
[image processing]: /content-management/image-processing/
```go-html-template
{{ $ic := images.Config "/static/images/a.jpg" }}
@@ -25,10 +23,9 @@ See [image processing] for an overview of Hugo's image pipeline.
Supported image formats include GIF, JPEG, PNG, TIFF, and WebP.
{{< note >}}
This is a legacy function, superseded by the [`Width`] and [`Height`] methods for [global resources](g), [page resources](g), and [remote resources](g). See the [image processing] section for details.
> [!note]
> This is a legacy function, superseded by the [`Width`] and [`Height`] methods for [global resources](g), [page resources](g), and [remote resources](g). See the [image processing] section for details.
[`Width`]: /methods/resource/width/
[`Height`]: /methods/resource/height/
[`Width`]: /methods/resource/width/
[image processing]: /content-management/image-processing/
{{< /note >}}
+6 -8
View File
@@ -14,9 +14,8 @@ params:
The `images.Mask` filter applies a mask to an image. Black pixels in the mask make the corresponding areas of the base image transparent, while white pixels keep them opaque. Color images are converted to grayscale for masking purposes. The mask is automatically resized to match the dimensions of the base image.
{{< note >}}
Of the formats supported by Hugo's imaging pipeline, only PNG and WebP have an alpha channel to support transparency. If your source image has a different format and you require transparent masked areas, convert it to either PNG or WebP as shown in the example below.
{{< /note >}}
> [!note]
> Of the formats supported by Hugo's imaging pipeline, only PNG and WebP have an alpha channel to support transparency. If your source image has a different format and you require transparent masked areas, convert it to either PNG or WebP as shown in the example below.
When applying a mask to a non-transparent image format such as JPEG, the masked areas will be filled with the color specified by the `bgColor` parameter in your [site configuration]. You can override that color with a `Process` image filter:
@@ -24,8 +23,6 @@ When applying a mask to a non-transparent image format such as JPEG, the masked
{{ $filter := images.Process "#00ff00" }}
```
[site configuration]: /configuration/imaging/
## Usage
Create a slice of filters, one for WebP conversion and the other for mask application:
@@ -56,9 +53,6 @@ You can also apply the filter using the [`Filter`] method on a 'Resource' object
{{ end }}
```
[`images.Filter`]: /functions/images/filter/
[`Filter`]: /methods/resource/filter/
## Example
Mask
@@ -75,3 +69,7 @@ Mask
filterArgs="images/examples/mask.png"
example=true
>}}
[`Filter`]: /methods/resource/filter/
[`images.Filter`]: /functions/images/filter/
[site configuration]: /configuration/imaging/
+10 -13
View File
@@ -20,19 +20,17 @@ The `images.QR` function encodes the given text into a [QR code] using the speci
Although the default option values are sufficient for most applications, you should test the rendered QR code both on-screen and in print.
[QR code]: https://en.wikipedia.org/wiki/QR_code
## Options
level
: (`string`) The error correction level to use when encoding the text, one of `low`, `medium`, `quartile`, or `high`. Default is `medium`.
Error correction level|Redundancy
:--|:--|:--
low|20%
medium|38%
quartile|55%
high|65%
Error correction level|Redundancy
:--|:--|:--
low|20%
medium|38%
quartile|55%
high|65%
scale
: (`int`) The number of image pixels per QR code module. Must be greater than or equal to `2`. Default is `4`.
@@ -40,8 +38,6 @@ scale
targetDir
: (`string`) The subdirectory within the [`publishDir`] where Hugo will place the generated image. Use Unix-style slashes (`/`) to separarate path segments. If empty or not provided, the image is placed directly in the `publishDir` root. Hugo automatically creates the necessary subdirectories if they don't exist.
[`publishDir`]: /configuration/all/#publishdir
## Examples
To create a QR code using the default values for `level` and `scale`:
@@ -115,9 +111,8 @@ If the QR code will be printed, use the default `scale` value of `4` pixels per
Avoid using Hugo's image processing methods to resize QR codes. Resizing can introduce blurring due to anti-aliasing when a QR code module occupies a fractional number of pixels.
{{< note >}}
Always test the rendered QR code both on-screen and in print.
{{< /note >}}
> [!note]
> Always test the rendered QR code both on-screen and in print.
## Shortcode
@@ -139,4 +134,6 @@ https://gohugo.io
The `qr` shortcode accepts several arguments including `level` and `scale`. See the [related documentation] for details.
[`publishDir`]: /configuration/all/#publishdir
[QR code]: https://en.wikipedia.org/wiki/QR_code
[related documentation]: /shortcodes/qr/
+12 -21
View File
@@ -10,9 +10,8 @@ params:
signatures: ['js.Batch [ID]']
---
{{< note >}}
For a runnable example of this feature, see [this test and demo repo](https://github.com/bep/hugojsbatchdemo/).
{{< /note >}}
> [!note]
> For a runnable example of this feature, see [this test and demo repo](https://github.com/bep/hugojsbatchdemo/).
The Batch `ID` is used to create the base directory for this batch. Forward slashes are allowed. `js.Batch` returns an object with an API with this structure:
@@ -182,7 +181,7 @@ Setting the `Config` for a batch can be done from any template (including shortc
### Build options
format
: (`string`) Currently only `esm` is supported in [ESBuild's code splitting].
: (`string`) Currently only `esm` is supported in ESBuild's [code splitting].
{{% include "/_common/functions/js/options.md" %}}
@@ -243,13 +242,10 @@ Each [`Resource`] will be of media type `application/javascript` or `text/css`.
In a template you would typically handle one group with a given `ID` (e.g. scripts for the current section). Because of the concurrent build, this needs to be done in a [`templates.Defer`] block:
{{< note >}}
The [`templates.Defer`] acts as a synchronisation point to handle scripts added concurrently by different templates. If you have a setup with where the batch is created in one go (in one template), you don't need it.
See [this discussion](https://discourse.gohugo.io/t/js-batch-with-simple-global-script/53002/5?u=bep) for more.
[`templates.Defer`]: /functions/templates/defer/
{{< /note >}}
> [!note]
> The [`templates.Defer`] acts as a synchronisation point to handle scripts added concurrently by different templates. If you have a setup with where the batch is created in one go (in one template), you don't need it.
>
> See [this discussion](https://discourse.gohugo.io/t/js-batch-with-simple-global-script/53002/5?u=bep) for more.
```go-html-template
{{ $group := .group }}
@@ -272,7 +268,7 @@ See [this discussion](https://discourse.gohugo.io/t/js-batch-with-simple-global-
## Known Issues
In the official documentation for [ESBuild's code splitting], there's a warning note in the header. The two issues are:
In the official documentation for ESBuild's [code splitting], there's a warning note in the header. The two issues are:
- `esm` is currently the only implemented output format. This means that it will not work for very old browsers. See [caniuse](https://caniuse.com/?search=ESM).
- There's a known import ordering issue.
@@ -289,28 +285,23 @@ import './lib2.js';
import './lib1.js';
console.log('entrypoints-workaround.js');
```
[build options]: #build-options
[`Resource`]: /methods/resource/
[`Resources`]: /methods/page/resources/
[`Resources.Mount`]: /methods/page/resources/#mount
[`Resources`]: /methods/page/resources/
[`templates.Defer`]: /functions/templates/defer/
[`templates.Defer`]: /functions/templates/defer/
[build options]: #build-options
[code splitting]: https://esbuild.github.io/api/#splitting
[config]: #config
[ESBuild's code splitting]: https://esbuild.github.io/api/#splitting
[ESBuild]: https://github.com/evanw/esbuild
[group]: #group
[instance]: #instance
[JavaScript import]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
[js.Batch Demo Repo]: https://github.com/bep/hugojsbatchdemo/
[map]: /functions/collections/dictionary/
[OptionsSetter]: #optionssetter
[page bundles]: /content-management/page-bundles/
[params options]: #params-options
[runner]: #runner
[script options]: #script-options
[script]: #script
[script options]: #script-options
[SetOptions]: #optionssetter
[with]: /functions/go-template/with/
+4 -5
View File
@@ -18,8 +18,6 @@ The `js.Build` function uses the [evanw/esbuild] package to:
- Minify
- Create source maps
[evanw/esbuild]: https://github.com/evanw/esbuild
```go-html-template
{{ with resources.Get "js/main.js" }}
{{ $opts := dict
@@ -100,9 +98,8 @@ Any imports in a file outside `assets` or that does not resolve to a component i
The start directory for resolving npm packages (aka. packages that live inside a `node_modules` directory) is always the main project directory.
{{< note >}}
If you're developing a theme/component that is supposed to be imported and depends on dependencies inside `package.json`, we recommend reading about [hugo mod npm pack](/commands/hugo_mod_npm_pack/), a tool to consolidate all the npm dependencies in a project.
{{< /note >}}
> [!note]
> If you're developing a theme/component that is supposed to be imported and depends on dependencies inside `package.json`, we recommend reading about [hugo mod npm pack](/commands/hugo_mod_npm_pack/), a tool to consolidate all the npm dependencies in a project.
## Examples
@@ -120,3 +117,5 @@ Or with options:
{{ $built := resources.Get "scripts/main.js" | js.Build $opts }}
<script src="{{ $built.RelPermalink }}" defer></script>
```
[evanw/esbuild]: https://github.com/evanw/esbuild
+21 -31
View File
@@ -16,17 +16,12 @@ The `lang.Translate` function returns the value associated with given key as def
If the key is not found in the translation table for the current language, the `lang.Translate` function falls back to the translation table for the [`defaultContentLanguage`].
[`defaultContentLanguage`]: /configuration/all/#defaultcontentlanguage
If the key is not found in the translation table for the `defaultContentLanguage`, the `lang.Translate` function returns an empty string.
{{< note >}}
To list missing and fallback translations, use the `--printI18nWarnings` flag when building your site.
To render placeholders for missing and fallback translations, set [`enableMissingTranslationPlaceholders`] to `true` in your site configuration.
[`enableMissingTranslationPlaceholders`]: /configuration/all/#enablemissingtranslationplaceholders
{{< /note >}}
> [!note]
> To list missing and fallback translations, use the `--printI18nWarnings` flag when building your site.
>
> To render placeholders for missing and fallback translations, set [`enableMissingTranslationPlaceholders`] to `true` in your site configuration.
## Translation tables
@@ -46,13 +41,8 @@ i18n/art-x-hugolang.toml
i18n/hugolang.toml
```
{{< note >}}
Private use subtags must not exceed 8 alphanumeric characters.
{{< /note >}}
[language key]: /configuration/languages/#language-keys
[RFC 5646]: https://datatracker.ietf.org/doc/html/rfc5646
[RFC 5646 § 2.2.7]: https://datatracker.ietf.org/doc/html/rfc5646#section-2.2.7
> [!note]
> Private use subtags must not exceed 8 alphanumeric characters.
## Simple translations
@@ -78,9 +68,8 @@ privacy = 'prywatność'
security = 'bezpieczeństwo'
{{< /code-toggle >}}
{{< note >}}
The examples below use the `T` alias for brevity.
{{< /note >}}
> [!note]
> The examples below use the `T` alias for brevity.
When viewing the English language site:
@@ -108,8 +97,6 @@ i18n/
The Unicode [CLDR Plural Rules chart] describes the pluralization categories for each language.
[CLDR Plural Rules chart]: https://www.unicode.org/cldr/charts/43/supplemental/language_plural_rules.html
The English translation table:
{{< code-toggle file=i18n/en >}}
@@ -138,9 +125,8 @@ many = '{{ . }} miesięcy'
other = '{{ . }} miesiąca'
{{< /code-toggle >}}
{{< note >}}
The examples below use the `T` alias for brevity.
{{< /note >}}
> [!note]
> The examples below use the `T` alias for brevity.
When viewing the English language site:
@@ -187,16 +173,13 @@ Template code:
{{ T "age" (dict "name" "John" "count" 3) }} → John is 3 years old.
```
{{< note >}}
Translation tables may contain both simple translations and translations with pluralization.
{{< /note >}}
> [!note]
> Translation tables may contain both simple translations and translations with pluralization.
## Reserved keys
Hugo uses the [go-i18n] package to look up values in translation tables. This package reserves the following keys for internal use:
[go-i18n]: https://github.com/nicksnyder/go-i18n
id
: (`string`) Uniquely identifies the message.
@@ -230,8 +213,6 @@ many
other
: (`string`) The content of the message for the [CLDR] plural form "other".
[CLDR]: https://www.unicode.org/cldr/charts/43/supplemental/language_plural_rules.html
If you need to provide a translation for one of the reserved keys, you can prepend the word with an underscore. For example:
{{< code-toggle file=i18n/es >}}
@@ -255,3 +236,12 @@ Then in your templates:
{{ T "_zero" }} → cero
{{ T "_other" }} → otro
```
[`defaultContentLanguage`]: /configuration/all/#defaultcontentlanguage
[`enableMissingTranslationPlaceholders`]: /configuration/all/#enablemissingtranslationplaceholders
[CLDR]: https://www.unicode.org/cldr/charts/43/supplemental/language_plural_rules.html
[CLDR Plural Rules chart]: https://www.unicode.org/cldr/charts/43/supplemental/language_plural_rules.html
[go-i18n]: https://github.com/nicksnyder/go-i18n
[language key]: /configuration/languages/#language-keys
[RFC 5646]: https://datatracker.ietf.org/doc/html/rfc5646
[RFC 5646 § 2.2.7]: https://datatracker.ietf.org/doc/html/rfc5646#section-2.2.7
+3 -5
View File
@@ -28,9 +28,7 @@ Use this function to:
- Create unique warnings as shown above; the [`warnf`] function suppresses duplicate messages
- Create unique target paths for the `resources.FromString` function where the target path is also the cache key
[`warnf`]: /functions/fmt/warnf/
[`resources.FromString`]: /functions/resources/fromstring/
> [!note]
> Due to concurrency, the value returned in a given template for a given page will vary from one build to the next. You cannot use this function to assign a static id to each page.
{{< note >}}
Due to concurrency, the value returned in a given template for a given page will vary from one build to the next. You cannot use this function to assign a static id to each page.
{{< /note >}}
[`warnf`]: /functions/fmt/warnf/
@@ -15,11 +15,10 @@ Without a [`return`] statement, the `partialCached` function returns a string of
The `partialCached` function can offer significant performance gains for complex templates that don't need to be re-rendered on every invocation.
{{< note >}}
Each Site (or language) has its own `partialCached` cache, so each site will execute a partial once.
Hugo renders pages in parallel, and will render the partial more than once with concurrent calls to the `partialCached` function. After Hugo caches the rendered partial, new pages entering the build pipeline will use the cached result.
{{< /note >}}
> [!note]
> Each Site (or language) has its own `partialCached` cache, so each site will execute a partial once.
>
> Hugo renders pages in parallel, and will render the partial more than once with concurrent calls to the `partialCached` function. After Hugo caches the rendered partial, new pages entering the build pipeline will use the cached result.
Here is the simplest usage:
+4 -6
View File
@@ -18,12 +18,10 @@ The [media type] is typically one of `image`, `text`, `audio`, `video`, or `appl
{{ end }}
```
{{< note >}}
This function operates on global resources. A global resource is a file within the `assets` directory, or within any directory mounted to the `assets` directory.
For page resources, use the [`Resources.ByType`] method on a `Page` object.
> [!note]
> This function operates on global resources. A global resource is a file within the `assets` directory, or within any directory mounted to the `assets` directory.
>
> For page resources, use the [`Resources.ByType`] method on a `Page` object.
[`Resources.ByType`]: /methods/page/resources/
{{< /note >}}
[media type]: https://en.wikipedia.org/wiki/Media_type
+2 -3
View File
@@ -23,6 +23,5 @@ The relative URL of the new published resource will be:
/img/new-image-name.jpg
```
{{< note >}}
Use the `resources.Copy` function with global, page, and remote resources.
{{< /note >}}
> [!note]
> Use the `resources.Copy` function with global, page, and remote resources.
@@ -14,13 +14,8 @@ The `resources.ExecuteAsTemplate` function returns a resource created from a Go
Hugo publishes the resource to the target path when you call its [`Publish`], [`Permalink`], or [`RelPermalink`] methods.
[`publish`]: /methods/resource/publish/
[`permalink`]: /methods/resource/permalink/
[`relpermalink`]: /methods/resource/relpermalink/
Let's say you have a CSS file that you wish to populate with values from your site configuration:
```go-html-template {file="assets/css/template.css"}
body {
background-color: {{ site.Params.style.bg_color }};
@@ -54,10 +49,13 @@ The example above:
The result is:
```css {file="public/css/main.css"}
body {
background-color: #fefefe;
color: #222;
}
```
[`publish`]: /methods/resource/publish/
[`permalink`]: /methods/resource/permalink/
[`relpermalink`]: /methods/resource/relpermalink/
+4 -5
View File
@@ -16,10 +16,9 @@ params:
{{ end }}
```
{{< note >}}
This function operates on global resources. A global resource is a file within the `assets` directory, or within any directory mounted to the `assets` directory.
For page resources, use the [`Resources.Get`] method on a `Page` object.
> [!note]
> This function operates on global resources. A global resource is a file within the `assets` directory, or within any directory mounted to the `assets` directory.
>
> For page resources, use the [`Resources.Get`] method on a `Page` object.
[`Resources.Get`]: /methods/page/resources/
{{< /note >}}
+6 -7
View File
@@ -16,14 +16,13 @@ params:
{{ end }}
```
{{< note >}}
This function operates on global resources. A global resource is a file within the `assets` directory, or within any directory mounted to the `assets` directory.
For page resources, use the [`Resources.GetMatch`] method on a `Page` object.
[`Resources.GetMatch`]: /methods/page/resources/
{{< /note >}}
> [!note]
> This function operates on global resources. A global resource is a file within the `assets` directory, or within any directory mounted to the `assets` directory.
>
> For page resources, use the [`Resources.GetMatch`] method on a `Page` object.
Hugo determines a match using a case-insensitive [glob](g) pattern.
{{% include "/_common/glob-patterns.md" %}}
[`Resources.GetMatch`]: /methods/page/resources/
+10 -15
View File
@@ -61,11 +61,10 @@ The `resources.GetRemote` function takes an optional map of options.
## Options examples
{{< note >}}
For brevity, the examples below do not include [error handling].
> [!note]
> For brevity, the examples below do not include [error handling].
[error handling]: #error-handling
{{< /note >}}
To include a header:
@@ -140,15 +139,12 @@ When retrieving remote data, use the [`transform.Unmarshal`] function to [unmars
{{ end }}
```
{{< note >}}
When retrieving remote data, a misconfigured server may send a response header with an incorrect [Content-Type]. For example, the server may set the Content-Type header to `application/octet-stream` instead of `application/json`.
In these cases, pass the resource `Content` through the `transform.Unmarshal` function instead of passing the resource itself. For example, in the above, do this instead:
`{{ $data = .Content | transform.Unmarshal }}`
[Content-Type]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
{{< /note >}}
> [!note]
> When retrieving remote data, a misconfigured server may send a response header with an incorrect [Content-Type]. For example, the server may set the Content-Type header to `application/octet-stream` instead of `application/json`.
>
> In these cases, pass the resource `Content` through the `transform.Unmarshal` function instead of passing the resource itself. For example, in the above, do this instead:
>
> `{{ $data = .Content | transform.Unmarshal }}`
## Error handling
@@ -156,9 +152,8 @@ Use the [`try`] statement to capture HTTP request errors. If you do not handle t
[`try`]: /functions/go-template/try
{{< note >}}
Hugo does not classify an HTTP response with status code 404 as an error. In this case `resources.GetRemote` returns nil.
{{< /note >}}
> [!note]
> Hugo does not classify an HTTP response with status code 404 as an error. In this case `resources.GetRemote` returns nil.
```go-html-template
{{ $url := "https://broken-example.org/images/a.jpg" }}
+5 -7
View File
@@ -16,16 +16,14 @@ params:
{{ end }}
```
{{< note >}}
This function operates on global resources. A global resource is a file within the `assets` directory, or within any directory mounted to the `assets` directory.
For page resources, use the [`Resources.Match`] method on a `Page` object.
[`Resources.Match`]: /methods/page/resources/
{{< /note >}}
> [!note]
> This function operates on global resources. A global resource is a file within the `assets` directory, or within any directory mounted to the `assets` directory.
>
> For page resources, use the [`Resources.Match`] method on a `Page` object.
Hugo determines a match using a case-insensitive [glob pattern].
{{% include "/_common/glob-patterns.md" %}}
[`Resources.Match`]: /methods/page/resources/
[glob pattern]: https://github.com/gobwas/glob#example
+13 -15
View File
@@ -21,17 +21,9 @@ In this example, after the build is complete, Hugo will:
3. [Minify] the CSS
4. [Fingerprint] the CSS
[autoprefixer]: https://github.com/postcss/autoprefixer
[fingerprint]: /functions/resources/fingerprint/
[minify]: /functions/resources/minify/
[postcss]: /functions/css/postcss/
[purgecss]: https://purgecss.com/plugins/postcss.html
Step 1
: Install [Node.js].
[node.js]: https://nodejs.org/en/download
Step 2
: Install the required Node.js packages in the root of your project:
@@ -42,8 +34,6 @@ npm i -D postcss postcss-cli autoprefixer @fullhuman/postcss-purgecss
Step 3
: Enable creation of the `hugo_stats.json` file when building the site. If you are only using this for the production build, consider placing it below [`config/production`].
[`config/production`]: /configuration/introduction/#configuration-directory
{{< code-toggle file=hugo >}}
[build.buildStats]
enable = true
@@ -51,8 +41,6 @@ enable = true
See the [configure build] documentation for details and options.
[configure build]: /configuration/build/
Step 4
: Create a PostCSS configuration file in the root of your project.
@@ -82,9 +70,8 @@ module.exports = {
};
```
{{< note >}}
{{% include "/_common/functions/postcss-windows-warning.md" %}}
{{< /note >}}
> [!note]
> If you are a Windows user, and the path to your project contains a space, you must place the PostCSS configuration within the package.json file. See [this example] and issue [#7333].
Step 5
: Place your CSS file within the `assets/css` directory.
@@ -148,3 +135,14 @@ You cannot manipulate the values returned from the resource's methods. For examp
{{ $css = $css | css.PostCSS | minify | fingerprint | resources.PostProcess }}
{{ $css.RelPermalink | strings.ToUpper }}
```
[#7333]: https://github.com/gohugoio/hugo/issues/7333
[`config/production`]: /configuration/introduction/#configuration-directory
[Autoprefixer]: https://github.com/postcss/autoprefixer
[configure build]: /configuration/build/
[Fingerprint]: /functions/resources/fingerprint/
[Minify]: /functions/resources/minify/
[Node.js]: https://nodejs.org/en
[PostCSS]: https://postcss.org/
[PurgeCSS]: https://github.com/FullHuman/purgecss
[this example]: https://github.com/postcss/postcss-load-config#packagejson
+4 -5
View File
@@ -28,8 +28,6 @@ Use of this type presents a security risk: the encapsulated content should come
See the [Go documentation] for details.
[Go documentation]: https://pkg.go.dev/html/template#CSS
## Example
Without a safe declaration:
@@ -45,9 +43,8 @@ Hugo renders the above to:
<p style="ZgotmplZ">foo</p>
```
{{< note >}}
`ZgotmplZ` is a special value that indicates that unsafe content reached a CSS or URL context at runtime.
{{< /note >}}
> [!note]
> `ZgotmplZ` is a special value that indicates that unsafe content reached a CSS or URL context at runtime.
To declare the string as safe:
@@ -61,3 +58,5 @@ Hugo renders the above to:
```html
<p style="color: red;">foo</p>
```
[Go documentation]: https://pkg.go.dev/html/template#CSS
+4 -5
View File
@@ -27,8 +27,6 @@ Use of this type presents a security risk: the encapsulated content should come
See the [Go documentation] for details.
[Go documentation]: https://pkg.go.dev/html/template#URL
## Example
Without a safe declaration:
@@ -44,9 +42,8 @@ Hugo renders the above to:
<a href="#ZgotmplZ">IRC</a>
```
{{< note >}}
`ZgotmplZ` is a special value that indicates that unsafe content reached a CSS or URL context at runtime.
{{< /note >}}
> [!note]
> `ZgotmplZ` is a special value that indicates that unsafe content reached a CSS or URL context at runtime.
To declare the string as safe:
@@ -60,3 +57,5 @@ Hugo renders the above to:
```html
<a href="irc://irc.freenode.net/#golang">IRC</a>
```
[Go documentation]: https://pkg.go.dev/html/template#URL
@@ -82,6 +82,5 @@ https://example.org
https://gohugo.io
```
{{< note >}}
You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
{{< /note >}}
> [!note]
> You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
+2 -3
View File
@@ -28,6 +28,5 @@ To limit the number of matches to one:
{{ findRE `(?s)<h2.*?>.*?</h2>` .Content 1 }}
```
{{< note >}}
You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
{{< /note >}}
> [!note]
> You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
+3 -5
View File
@@ -32,9 +32,7 @@ Use `$1`, `$2`, etc. within the replacement string to insert the content of each
{{ replaceRE "^https?://([^/]+).*" "$1" $s }} → gohugo.io
```
{{< note >}}
You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
{{< /note >}}
> [!note]
> You can write and test your regular expression using [regex101.com]. Be sure to select the Go flavor before you begin.
[RE2]: https://github.com/google/re2/wiki/Syntax
[string literal]: https://go.dev/ref/spec#String_literals
[regex101.com]: https://regex101.com/
+2 -3
View File
@@ -18,8 +18,7 @@ Examples:
{{ split "abc" "" }} → ["a", "b", "c"]
```
{{< note >}}
The `strings.Split` function essentially does the opposite of the [`collections.Delimit`] function. While `split` creates a slice from a string, `delimit` creates a string from a slice.
> [!note]
> The `strings.Split` function essentially does the opposite of the [`collections.Delimit`] function. While `split` creates a slice from a string, `delimit` creates a string from a slice.
[`collections.Delimit`]: /functions/collections/delimit/
{{< /note >}}
+2 -3
View File
@@ -18,8 +18,7 @@ Since Go templates are HTML-aware, `truncate` will intelligently handle normal s
{{ "<em>Keep my HTML</em>" | safeHTML | truncate 10 }} → <em>Keep my …</em>
```
{{< note >}}
If you have a raw string that contains HTML tags you want to remain treated as HTML, you will need to convert the string to HTML using the [`safeHTML`]function before sending the value to `truncate`. Otherwise, the HTML tags will be escaped when passed through the `truncate` function.
> [!note]
> If you have a raw string that contains HTML tags you want to remain treated as HTML, you will need to convert the string to HTML using the [`safeHTML`]function before sending the value to `truncate`. Otherwise, the HTML tags will be escaped when passed through the `truncate` function.
[`safeHTML`]: /functions/safe/html/
{{< /note >}}
+4 -7
View File
@@ -42,13 +42,10 @@ In some rare use cases, you may need to defer the execution of a template until
{{ end }}
```
{{< note >}}
This function only works in combination with the `with` keyword.
{{< /note >}}
{{< note >}}
Variables defined on the outside are not visible on the inside and vice versa. To pass in data, use the `data` [option](#options).
{{< /note >}}
> [!note]
> This function only works in combination with the `with` keyword.
>
> Variables defined on the outside are not visible on the inside and vice versa. To pass in data, use the `data` [option](#options).
For the above to work well when running the server (or `hugo -w`), you want to have a configuration similar to this:
+1 -4
View File
@@ -18,14 +18,11 @@ See the list of [emoji shortcodes] for available emoticons.
The `emojify` function can be called in your templates but not directly in your content files by default. For emojis in content files, set [`enableEmoji`] to `true` in your site's configuration. Then you can write emoji shorthand directly into your content files;
[`enableEmoji`] :/configuration/all/#enableEmoji
```text
I :heart: Hugo!
```
I :heart: Hugo!
[`enableEmoji`]: /configuration/all/#enableemoji
[emoji shortcodes]: /quick-reference/emojis/
[sc]: /templates/shortcode/
[scsource]: https://github.com/gohugoio/hugo/tree/master/docs/layouts/shortcodes
@@ -19,11 +19,9 @@ If the resulting HTML is a single paragraph, Hugo removes the wrapping `p` tags
To keep the wrapping `p` tags for a single paragraph, use the [`RenderString`] method on the `Page` object, setting the `display` option to `block`.
[`RenderString`]: /methods/page/renderstring/
> [!note]
> Although the `markdownify` function honors [Markdown render hooks] when rendering Markdown to HTML, use the `RenderString` method instead of `markdownify` if a render hook accesses `.Page` context. See issue [#9692] for details.
{{< note >}}
Although the `markdownify` function honors [Markdown render hooks] when rendering Markdown to HTML, use the `RenderString` method instead of `markdownify` if a render hook accesses `.Page` context. See issue [#9692] for details.
[Markdown render hooks]: /render-hooks/
[#9692]: https://github.com/gohugoio/hugo/issues/9692
{{< /note >}}
[`RenderString`]: /methods/page/renderstring/
[Markdown render hooks]: /render-hooks/
@@ -19,9 +19,8 @@ params:
- `image`. Note that the image handling is currently very simple; we link to the `asset.url` using `asset.altText` as the image alt text and `asset.title` as the title. For more fine grained control you may want to process the images in a [image render hook](/render-hooks/images/).
- `code` (see the [code-input](https://www.sanity.io/plugins/code-input) plugin). Code will be rendered as [fenced code blocks](/contribute/documentation/#fenced-code-blocks) with any file name provided passed on as a markdown attribute.
{{< note >}}
Since the Portable Text gets converted to Markdown before it gets passed to Hugo, rendering of links, headings, images and code blocks can be controlled with [Render Hooks](https://gohugo.io/render-hooks/).
{{< /note >}}
> [!note]
> Since the Portable Text gets converted to Markdown before it gets passed to Hugo, rendering of links, headings, images and code blocks can be controlled with [Render Hooks](https://gohugo.io/render-hooks/).
## Example
+4 -5
View File
@@ -13,11 +13,10 @@ aliases: [/functions/transform.remarshal]
The format must be one of `json`, `toml`, `yaml`, or `xml`. If the input is a string of serialized data, it must be valid JSON, TOML, YAML, or XML.
{{< note >}}
This function is primarily a helper for Hugo's documentation, used to convert configuration and front matter examples to JSON, TOML, and YAML.
This is not a general purpose converter, and may change without notice if required for Hugo's documentation site.
{{< /note >}}
> [!note]
> This function is primarily a helper for Hugo's documentation, used to convert configuration and front matter examples to JSON, TOML, and YAML.
>
> This is not a general purpose converter, and may change without notice if required for Hugo's documentation site.
Example 1
: Convert a string of TOML to JSON.

Some files were not shown because too many files have changed in this diff Show More