From 7c62d6ef1654c0383eae474d3bd9ddf7754c1f30 Mon Sep 17 00:00:00 2001 From: Bjørn Erik Pedersen Date: Mon, 7 Aug 2023 10:35:12 +0200 Subject: Squashed 'docs/' changes from c43daf45f..a7e1e9be8 a7e1e9be8 Clarify front matter date fields 69df4fc22 Clarify how to determine if .Inner is populated 9046bf424 Document strings.ContainsNonSpace 8dbe5df90 Fix indentation and broken image 48ad4124e Typo: functions/after.md d4c01b57b Link to detailed descriptions of canonfiyURLs and relativeURLs 4d9597302 Explain behaviour when appending to a slice containing other slices 69e24e44e Standardize right arrow usage 01b378726 Remove references to Google's Universal Analytics and the async template d415bae24 Use shared file to describe regex syntax e75dee6b8 snap: How to enable or revoke access to SSH keys feed2d1c0 Remove hasPrefix and hasSuffix in favor of namespaced versions 3c6d2cfe5 security: Use default execution settings 461b5fcaf netlify: Hugo 0.116.1 95fac27a5 configuration: correct cacheDir description cd9f1f929 configuration: Fix broken link 605394de4 netlify: Upgrade to Hugo 0.116.0 baf2a0f7b Merge branch 'tempv0.116.0' ee51a9323 Update requirements for building from source 40189956d Editor tools: Remove duplicate sentence fb0ff2621 docs: Regenerate CLI docs e8a5665c4 Update where.md 7bc5cf15d Update hosting instructions 018a04314 docs: Update where d33ae91cf docs: Update where function operators 9a108a664 docs: Rework the cacheDir documentation git-subtree-dir: docs git-subtree-split: a7e1e9be851b95e636ab5360e5151156b4f89044 --- config/_default/security.toml | 4 - content/en/commands/hugo.md | 2 +- content/en/commands/hugo_completion_bash.md | 1 + content/en/commands/hugo_config.md | 2 +- content/en/commands/hugo_config_mounts.md | 2 +- content/en/commands/hugo_mod_clean.md | 2 +- content/en/commands/hugo_mod_graph.md | 2 +- content/en/commands/hugo_mod_init.md | 2 +- content/en/commands/hugo_mod_npm_pack.md | 2 +- content/en/commands/hugo_mod_tidy.md | 2 +- content/en/commands/hugo_mod_vendor.md | 2 +- content/en/commands/hugo_mod_verify.md | 2 +- content/en/commands/hugo_new_content.md | 2 +- content/en/commands/hugo_server.md | 2 +- content/en/content-management/multilingual.md | 2 +- content/en/content-management/summaries.md | 18 ++-- content/en/content-management/toc.md | 12 +-- content/en/functions/adddate.md | 14 +-- content/en/functions/after.md | 2 +- content/en/functions/anchorize.md | 12 +-- content/en/functions/append.md | 8 ++ content/en/functions/common/index.md | 3 + content/en/functions/common/regular-expressions.md | 8 ++ content/en/functions/fileExists.md | 14 +-- content/en/functions/findRe.md | 16 +--- content/en/functions/findresubmatch.md | 16 +--- content/en/functions/getenv.md | 8 +- content/en/functions/hasPrefix.md | 20 ----- content/en/functions/hasSuffix.md | 21 ----- content/en/functions/merge.md | 24 +++--- content/en/functions/os.Stat.md | 10 +-- content/en/functions/readdir.md | 2 +- content/en/functions/replacere.md | 16 +--- content/en/functions/scratch.md | 2 +- content/en/functions/strings.ContainsNonSpace.md | 27 ++++++ content/en/functions/transform.Unmarshal.md | 14 +-- content/en/functions/uniq.md | 2 +- content/en/functions/urlize.md | 24 +++--- content/en/functions/where.md | 16 +++- content/en/getting-started/configuration.md | 23 ++++- .../hosting-on-github/index.md | 2 +- .../en/hosting-and-deployment/hosting-on-gitlab.md | 7 +- .../hosting-and-deployment/hosting-on-netlify.md | 4 +- .../en/installation/common/05-build-from-source.md | 13 +-- content/en/installation/linux.md | 8 +- content/en/installation/windows.md | 5 +- content/en/news/0.25-relnotes/index.md | 2 - content/en/templates/homepage.md | 4 +- content/en/templates/internal.md | 30 ++----- content/en/templates/lists/index.md | 20 ++--- content/en/templates/section-templates.md | 22 ++--- content/en/templates/shortcode-templates.md | 8 +- content/en/templates/single-page-templates.md | 8 +- content/en/tools/editors.md | 6 +- content/en/variables/page.md | 99 ++++++++++------------ netlify.toml | 8 +- 56 files changed, 293 insertions(+), 316 deletions(-) create mode 100644 content/en/functions/common/index.md create mode 100644 content/en/functions/common/regular-expressions.md delete mode 100644 content/en/functions/hasPrefix.md delete mode 100644 content/en/functions/hasSuffix.md create mode 100644 content/en/functions/strings.ContainsNonSpace.md diff --git a/config/_default/security.toml b/config/_default/security.toml index 2be3f1ba8..8bd91945f 100644 --- a/config/_default/security.toml +++ b/config/_default/security.toml @@ -1,10 +1,6 @@ enableInlineShortcodes = false - [exec] - allow = ['^go$'] - osEnv = ['^PATH$'] - [funcs] getenv = ['^HUGO_', '^REPOSITORY_URL$', '^BRANCH$'] diff --git a/content/en/commands/hugo.md b/content/en/commands/hugo.md index f521a2d1f..fa8f6d1ed 100644 --- a/content/en/commands/hugo.md +++ b/content/en/commands/hugo.md @@ -27,7 +27,7 @@ hugo [flags] -D, --buildDrafts include content marked as draft -E, --buildExpired include expired content -F, --buildFuture include content with publishdate in the future - --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/ + --cacheDir string filesystem path to cache directory --cleanDestinationDir remove files from destination not found in static directories --clock string set the clock used by Hugo, e.g. --clock 2021-11-06T22:30:00.00+09:00 --config string config file (default is hugo.yaml|json|toml) diff --git a/content/en/commands/hugo_completion_bash.md b/content/en/commands/hugo_completion_bash.md index 231804d09..875ecfc19 100644 --- a/content/en/commands/hugo_completion_bash.md +++ b/content/en/commands/hugo_completion_bash.md @@ -62,3 +62,4 @@ hugo completion bash ### SEE ALSO * [hugo completion](/commands/hugo_completion/) - Generate the autocompletion script for the specified shell + diff --git a/content/en/commands/hugo_config.md b/content/en/commands/hugo_config.md index e910a3235..3ec3748a3 100644 --- a/content/en/commands/hugo_config.md +++ b/content/en/commands/hugo_config.md @@ -19,7 +19,7 @@ hugo config [command] [flags] ``` -b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/ - --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/ + --cacheDir string filesystem path to cache directory -c, --contentDir string filesystem path to content directory --format string preferred file format (toml, yaml or json) (default "toml") -h, --help help for config diff --git a/content/en/commands/hugo_config_mounts.md b/content/en/commands/hugo_config_mounts.md index 59087c771..90b171912 100644 --- a/content/en/commands/hugo_config_mounts.md +++ b/content/en/commands/hugo_config_mounts.md @@ -15,7 +15,7 @@ hugo config mounts [flags] [args] ``` -b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/ - --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/ + --cacheDir string filesystem path to cache directory -c, --contentDir string filesystem path to content directory -h, --help help for mounts -t, --theme strings themes to use (located in /themes/THEMENAME/) diff --git a/content/en/commands/hugo_mod_clean.md b/content/en/commands/hugo_mod_clean.md index 6ca413993..c1c2b0c0d 100644 --- a/content/en/commands/hugo_mod_clean.md +++ b/content/en/commands/hugo_mod_clean.md @@ -20,7 +20,7 @@ hugo mod clean [flags] [args] ``` --all clean entire module cache -b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/ - --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/ + --cacheDir string filesystem path to cache directory -c, --contentDir string filesystem path to content directory -h, --help help for clean --pattern string pattern matching module paths to clean (all if not set), e.g. "**hugo*" diff --git a/content/en/commands/hugo_mod_graph.md b/content/en/commands/hugo_mod_graph.md index 55c95ca23..a2e2b51a3 100644 --- a/content/en/commands/hugo_mod_graph.md +++ b/content/en/commands/hugo_mod_graph.md @@ -21,7 +21,7 @@ hugo mod graph [flags] [args] ``` -b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/ - --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/ + --cacheDir string filesystem path to cache directory --clean delete module cache for dependencies that fail verification -c, --contentDir string filesystem path to content directory -h, --help help for graph diff --git a/content/en/commands/hugo_mod_init.md b/content/en/commands/hugo_mod_init.md index bef38c050..49b2609e1 100644 --- a/content/en/commands/hugo_mod_init.md +++ b/content/en/commands/hugo_mod_init.md @@ -26,7 +26,7 @@ hugo mod init [flags] [args] ``` -b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/ - --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/ + --cacheDir string filesystem path to cache directory -c, --contentDir string filesystem path to content directory -h, --help help for init -t, --theme strings themes to use (located in /themes/THEMENAME/) diff --git a/content/en/commands/hugo_mod_npm_pack.md b/content/en/commands/hugo_mod_npm_pack.md index 4f37f40df..30214d556 100644 --- a/content/en/commands/hugo_mod_npm_pack.md +++ b/content/en/commands/hugo_mod_npm_pack.md @@ -29,7 +29,7 @@ hugo mod npm pack [flags] [args] ``` -b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/ - --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/ + --cacheDir string filesystem path to cache directory -c, --contentDir string filesystem path to content directory -h, --help help for pack -t, --theme strings themes to use (located in /themes/THEMENAME/) diff --git a/content/en/commands/hugo_mod_tidy.md b/content/en/commands/hugo_mod_tidy.md index b28c6a3c2..803ef1c5b 100644 --- a/content/en/commands/hugo_mod_tidy.md +++ b/content/en/commands/hugo_mod_tidy.md @@ -15,7 +15,7 @@ hugo mod tidy [flags] [args] ``` -b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/ - --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/ + --cacheDir string filesystem path to cache directory -c, --contentDir string filesystem path to content directory -h, --help help for tidy -t, --theme strings themes to use (located in /themes/THEMENAME/) diff --git a/content/en/commands/hugo_mod_vendor.md b/content/en/commands/hugo_mod_vendor.md index 3df563621..3a829d5fd 100644 --- a/content/en/commands/hugo_mod_vendor.md +++ b/content/en/commands/hugo_mod_vendor.md @@ -21,7 +21,7 @@ hugo mod vendor [flags] [args] ``` -b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/ - --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/ + --cacheDir string filesystem path to cache directory -c, --contentDir string filesystem path to content directory -h, --help help for vendor -t, --theme strings themes to use (located in /themes/THEMENAME/) diff --git a/content/en/commands/hugo_mod_verify.md b/content/en/commands/hugo_mod_verify.md index 86f908564..b647a2cbb 100644 --- a/content/en/commands/hugo_mod_verify.md +++ b/content/en/commands/hugo_mod_verify.md @@ -19,7 +19,7 @@ hugo mod verify [flags] [args] ``` -b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/ - --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/ + --cacheDir string filesystem path to cache directory --clean delete module cache for dependencies that fail verification -c, --contentDir string filesystem path to content directory -h, --help help for verify diff --git a/content/en/commands/hugo_new_content.md b/content/en/commands/hugo_new_content.md index c7f87631c..dd646766b 100644 --- a/content/en/commands/hugo_new_content.md +++ b/content/en/commands/hugo_new_content.md @@ -26,7 +26,7 @@ hugo new content [path] [flags] ``` -b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/ - --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/ + --cacheDir string filesystem path to cache directory -c, --contentDir string filesystem path to content directory --editor string edit new content with this editor, if provided -f, --force overwrite file if it already exists diff --git a/content/en/commands/hugo_server.md b/content/en/commands/hugo_server.md index 601fd4406..49cd1867b 100644 --- a/content/en/commands/hugo_server.md +++ b/content/en/commands/hugo_server.md @@ -33,7 +33,7 @@ hugo server [command] [flags] -D, --buildDrafts include content marked as draft -E, --buildExpired include expired content -F, --buildFuture include content with publishdate in the future - --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/ + --cacheDir string filesystem path to cache directory --cleanDestinationDir remove files from destination not found in static directories -c, --contentDir string filesystem path to content directory --disableBrowserError do not show build errors in the browser diff --git a/content/en/content-management/multilingual.md b/content/en/content-management/multilingual.md index 4c1f6446e..849df681f 100644 --- a/content/en/content-management/multilingual.md +++ b/content/en/content-management/multilingual.md @@ -506,7 +506,7 @@ See [lang.FormatNumber] and [lang.FormatNumberCustom] for details. With this template code: ```go-html-template -{{ 512.5032 | lang.FormatPercent 2 }} ---> 512.50% +{{ 512.5032 | lang.FormatPercent 2 }} → 512.50% ``` The rendered page displays: diff --git a/content/en/content-management/summaries.md b/content/en/content-management/summaries.md index 4f94f95f2..74c5623cb 100644 --- a/content/en/content-management/summaries.md +++ b/content/en/content-management/summaries.md @@ -85,19 +85,19 @@ You can show content summaries with the following code. You could use the follow {{< code file="page-list-with-summaries.html" >}} {{ range first 10 .Pages }} -
- -
-

{{ .Title }}

- {{ .Summary }} -
- {{ if .Truncated }} + + {{ end }} +
{{ end }} {{< /code >}} diff --git a/content/en/content-management/toc.md b/content/en/content-management/toc.md index e1f24378e..ca179c77d 100644 --- a/content/en/content-management/toc.md +++ b/content/en/content-management/toc.md @@ -50,17 +50,17 @@ The following is an example of a very basic [single page template]: {{< code file="layout/_default/single.html" >}} {{ define "main" }} -
+
-
+

{{ .Title }}

-
- {{ .Content }} +
+ {{ .Content }}
-
+
{{ end }} {{< /code >}} diff --git a/content/en/functions/adddate.md b/content/en/functions/adddate.md index 96a9df833..cae270fb8 100644 --- a/content/en/functions/adddate.md +++ b/content/en/functions/adddate.md @@ -13,11 +13,11 @@ relatedfuncs: [now] ```go-html-template {{ $d := "2022-01-01" | time.AsTime }} -{{ $d.AddDate 0 0 1 | time.Format "2006-01-02" }} --> 2022-01-02 -{{ $d.AddDate 0 1 1 | time.Format "2006-01-02" }} --> 2022-02-02 -{{ $d.AddDate 1 1 1 | time.Format "2006-01-02" }} --> 2023-02-02 +{{ $d.AddDate 0 0 1 | time.Format "2006-01-02" }} → 2022-01-02 +{{ $d.AddDate 0 1 1 | time.Format "2006-01-02" }} → 2022-02-02 +{{ $d.AddDate 1 1 1 | time.Format "2006-01-02" }} → 2023-02-02 -{{ $d.AddDate -1 -1 -1 | time.Format "2006-01-02" }} --> 2020-11-30 +{{ $d.AddDate -1 -1 -1 | time.Format "2006-01-02" }} → 2020-11-30 ``` {{% note %}} @@ -28,11 +28,11 @@ See [this explanation](https://github.com/golang/go/issues/31145#issuecomment-47 ```go-html-template {{ $d := "2023-01-31" | time.AsTime }} -{{ $d.AddDate 0 1 0 | time.Format "2006-01-02" }} --> 2023-03-03 +{{ $d.AddDate 0 1 0 | time.Format "2006-01-02" }} → 2023-03-03 {{ $d := "2024-01-31" | time.AsTime }} -{{ $d.AddDate 0 1 0 | time.Format "2006-01-02" }} --> 2024-03-02 +{{ $d.AddDate 0 1 0 | time.Format "2006-01-02" }} → 2024-03-02 {{ $d := "2024-02-29" | time.AsTime }} -{{ $d.AddDate 1 0 0 | time.Format "2006-01-02" }} --> 2025-03-01 +{{ $d.AddDate 1 0 0 | time.Format "2006-01-02" }} → 2025-03-01 ``` diff --git a/content/en/functions/after.md b/content/en/functions/after.md index 5318d3b0c..85aa6104d 100644 --- a/content/en/functions/after.md +++ b/content/en/functions/after.md @@ -33,7 +33,7 @@ You can use `after` in combination with the [`first` function] and Hugo's [power

Featured Article

{{ range first 1 .Pages.ByPublishDate.Reverse }}
-

{{ .Title }}

+

{{ .Title }}

{{ .Description }}

{{ end }} diff --git a/content/en/functions/anchorize.md b/content/en/functions/anchorize.md index bdf322a6e..51ef67bb2 100644 --- a/content/en/functions/anchorize.md +++ b/content/en/functions/anchorize.md @@ -15,10 +15,10 @@ If [Goldmark](/getting-started/configuration-markup#goldmark) is set as `default Since the `defaultMarkdownHandler` and this template function use the same sanitizing logic, you can use the latter to determine the ID of a header for linking with anchor tags. ```go-html-template -{{ anchorize "This is a header" }} --> "this-is-a-header" -{{ anchorize "This is also a header" }} --> "this-is-also----a-header" -{{ anchorize "main.go" }} --> "maingo" -{{ anchorize "Article 123" }} --> "article-123" -{{ anchorize "<- Let's try this, shall we?" }} --> "--lets-try-this-shall-we" -{{ anchorize "Hello, 世界" }} --> "hello-世界" +{{ anchorize "This is a header" }} → "this-is-a-header" +{{ anchorize "This is also a header" }} → "this-is-also----a-header" +{{ anchorize "main.go" }} → "maingo" +{{ anchorize "Article 123" }} → "article-123" +{{ anchorize "<- Let's try this, shall we?" }} → "--lets-try-this-shall-we" +{{ anchorize "Hello, 世界" }} → "hello-世界" ``` diff --git a/content/en/functions/append.md b/content/en/functions/append.md index 626bc1242..6d7ffa245 100644 --- a/content/en/functions/append.md +++ b/content/en/functions/append.md @@ -26,4 +26,12 @@ The same example appending a slice to a slice: {{ $s = $s | append (slice "d" "e") }} ``` +If a slice contains other slices, further slices will be appended as values: + +```go-html-template +{{ $s := slice (slice "a" "b") (slice "c" "d") }} +{{ $s = $s | append (slice "e" "f") (slice "g" "h") }} +{{/* $s now contains a [][]string containing four slices: ["a" "b"], ["c" "d"], ["e" "f"], and ["g" "h"] */}} +``` + The `append` function works for all types, including `Pages`. diff --git a/content/en/functions/common/index.md b/content/en/functions/common/index.md new file mode 100644 index 000000000..cbb7365a6 --- /dev/null +++ b/content/en/functions/common/index.md @@ -0,0 +1,3 @@ ++++ +headless = true ++++ diff --git a/content/en/functions/common/regular-expressions.md b/content/en/functions/common/regular-expressions.md new file mode 100644 index 000000000..9da340849 --- /dev/null +++ b/content/en/functions/common/regular-expressions.md @@ -0,0 +1,8 @@ +When specifying the regular expression, use a raw [string literal] (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes. + +Go's regular expression package implements the [RE2 syntax]. The RE2 syntax is a subset of that accepted by [PCRE], roughly speaking, and with various [caveats]. Note that the RE2 `\C` escape sequence is not supported. + +[caveats]: https://swtch.com/~rsc/regexp/regexp3.html#caveats +[PCRE]: https://www.pcre.org/ +[RE2 syntax]: https://github.com/google/re2/wiki/Syntax/ +[string literal]: https://go.dev/ref/spec#String_literals diff --git a/content/en/functions/fileExists.md b/content/en/functions/fileExists.md index 5a365b7c1..f7b5c37e0 100644 --- a/content/en/functions/fileExists.md +++ b/content/en/functions/fileExists.md @@ -24,11 +24,11 @@ content/ The function returns these values: ```go-html-template -{{ os.FileExists "content" }} --> true -{{ os.FileExists "content/news" }} --> true -{{ os.FileExists "content/news/article-1" }} --> false -{{ os.FileExists "content/news/article-1.md" }} --> true -{{ os.FileExists "news" }} --> true -{{ os.FileExists "news/article-1" }} --> false -{{ os.FileExists "news/article-1.md" }} --> true +{{ os.FileExists "content" }} → true +{{ os.FileExists "content/news" }} → true +{{ os.FileExists "content/news/article-1" }} → false +{{ os.FileExists "content/news/article-1.md" }} → true +{{ os.FileExists "news" }} → true +{{ os.FileExists "news/article-1" }} → false +{{ os.FileExists "news/article-1.md" }} → true ``` diff --git a/content/en/functions/findRe.md b/content/en/functions/findRe.md index 0b8978ec6..3c977118c 100644 --- a/content/en/functions/findRe.md +++ b/content/en/functions/findRe.md @@ -13,21 +13,7 @@ relatedfuncs: [findRESubmatch, replaceRE] --- By default, `findRE` finds all matches. You can limit the number of matches with an optional LIMIT parameter. -When specifying the regular expression, use a raw [string literal] (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes. - -[string literal]: https://go.dev/ref/spec#String_literals - -This function uses the [RE2] regular expression library. See the [RE2 syntax documentation] for details. Note that the RE2 `\C` escape sequence is not supported. - -[RE2]: https://github.com/google/re2/ -[RE2 syntax documentation]: https://github.com/google/re2/wiki/Syntax/ - -{{% note %}} -The RE2 syntax is a subset of that accepted by [PCRE], roughly speaking, and with various [caveats]. - -[caveats]: https://swtch.com/~rsc/regexp/regexp3.html#caveats -[PCRE]: https://www.pcre.org/ -{{% /note %}} +{{% readfile file="/functions/common/regular-expressions.md" %}} This example returns a slice of all second level headings (`h2` elements) within the rendered `.Content`: diff --git a/content/en/functions/findresubmatch.md b/content/en/functions/findresubmatch.md index e1085a9c9..1f0f26b49 100644 --- a/content/en/functions/findresubmatch.md +++ b/content/en/functions/findresubmatch.md @@ -14,21 +14,7 @@ relatedfuncs: [findRE, replaceRE] By default, `findRESubmatch` finds all matches. You can limit the number of matches with an optional LIMIT parameter. A return value of nil indicates no match. -When specifying the regular expression, use a raw [string literal] (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes. - -[string literal]: https://go.dev/ref/spec#String_literals - -This function uses the [RE2] regular expression library. See the [RE2 syntax documentation] for details. Note that the RE2 `\C` escape sequence is not supported. - -[RE2]: https://github.com/google/re2/ -[RE2 syntax documentation]: https://github.com/google/re2/wiki/Syntax/ - -{{% note %}} -The RE2 syntax is a subset of that accepted by [PCRE], roughly speaking, and with various [caveats]. - -[caveats]: https://swtch.com/~rsc/regexp/regexp3.html#caveats -[PCRE]: https://www.pcre.org/ -{{% /note %}} +{{% readfile file="/functions/common/regular-expressions.md" %}} ## Demonstrative examples diff --git a/content/en/functions/getenv.md b/content/en/functions/getenv.md index e014b7ad5..daeeb6532 100644 --- a/content/en/functions/getenv.md +++ b/content/en/functions/getenv.md @@ -12,8 +12,8 @@ relatedfuncs: [] Examples: ```go-html-template -{{ os.Getenv "HOME" }} --> /home/victor -{{ os.Getenv "USER" }} --> victor +{{ os.Getenv "HOME" }} → /home/victor +{{ os.Getenv "USER" }} → victor ``` You can pass values when building your site: @@ -31,8 +31,8 @@ hugo And then retrieve the values within a template: ```go-html-template -{{ os.Getenv "MY_VAR1" }} --> foo -{{ os.Getenv "MY_VAR2" }} --> bar +{{ os.Getenv "MY_VAR1" }} → foo +{{ os.Getenv "MY_VAR2" }} → bar ``` With Hugo v0.91.0 and later, you must explicitly allow access to environment variables. For details, review [Hugo's Security Policy](/about/security-model/#security-policy). By default, environment variables beginning with `HUGO_` are allowed when using the `os.Getenv` function. diff --git a/content/en/functions/hasPrefix.md b/content/en/functions/hasPrefix.md deleted file mode 100644 index 264044577..000000000 --- a/content/en/functions/hasPrefix.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: hasprefix -description: Tests whether a string begins with prefix. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 -categories: [functions] -menu: - docs: - parent: "functions" -keywords: [strings] -signature: ["hasPrefix STRING PREFIX"] -workson: [] -hugoversion: -relatedfuncs: [hasSuffix] -deprecated: false -aliases: [] ---- - -* `{{ hasPrefix "Hugo" "Hu" }}` → true diff --git a/content/en/functions/hasSuffix.md b/content/en/functions/hasSuffix.md deleted file mode 100644 index 5ab38866d..000000000 --- a/content/en/functions/hasSuffix.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -title: hassuffix -linkTitle: hasSuffix -description: Tests whether a string ends with suffix. -date: 2023-03-01 -publishdate: 2023-03-01 -lastmod: 2023-03-01 -categories: [functions] -menu: -docs: -parent: "functions" -keywords: [strings] -signature: ["hasSuffix STRING SUFFIX"] -workson: [] -hugoversion: -relatedfuncs: [hasPrefix] -deprecated: false -aliases: [] ---- - -* `{{ hasSuffix "Hugo" "go" }}` → true diff --git a/content/en/functions/merge.md b/content/en/functions/merge.md index 68e561450..ed370549e 100644 --- a/content/en/functions/merge.md +++ b/content/en/functions/merge.md @@ -27,9 +27,9 @@ Example 1 ```go-html-template {{ $merged := merge $m1 $m2 $m3 }} -{{ $merged.x }} --> baz -{{ $merged.y }} --> wobble -{{ $merged.z.a }} --> huey +{{ $merged.x }} → baz +{{ $merged.y }} → wobble +{{ $merged.z.a }} → huey ``` Example 2 @@ -37,9 +37,9 @@ Example 2 ```go-html-template {{ $merged := merge $m3 $m2 $m1 }} -{{ $merged.x }} --> foo -{{ $merged.y }} --> wibble -{{ $merged.z.a }} --> huey +{{ $merged.x }} → foo +{{ $merged.y }} → wibble +{{ $merged.z.a }} → huey ``` Example 3 @@ -47,9 +47,9 @@ Example 3 ```go-html-template {{ $merged := merge $m2 $m3 $m1 }} -{{ $merged.x }} --> foo -{{ $merged.y }} --> wobble -{{ $merged.z.a }} --> huey +{{ $merged.x }} → foo +{{ $merged.y }} → wobble +{{ $merged.z.a }} → huey ``` Example 4 @@ -57,9 +57,9 @@ Example 4 ```go-html-template {{ $merged := merge $m1 $m3 $m2 }} -{{ $merged.x }} --> bar -{{ $merged.y }} --> wibble -{{ $merged.z.a }} --> huey +{{ $merged.x }} → bar +{{ $merged.y }} → wibble +{{ $merged.z.a }} → huey ``` {{% note %}} diff --git a/content/en/functions/os.Stat.md b/content/en/functions/os.Stat.md index 9ace3b8bf..51d35ae2f 100644 --- a/content/en/functions/os.Stat.md +++ b/content/en/functions/os.Stat.md @@ -13,13 +13,13 @@ The `os.Stat` function attempts to resolve the path relative to the root of your ```go-html-template {{ $f := os.Stat "README.md" }} -{{ $f.IsDir }} --> false (bool) -{{ $f.ModTime }} --> 2021-11-25 10:06:49.315429236 -0800 PST (time.Time) -{{ $f.Name }} --> README.md (string) -{{ $f.Size }} --> 241 (int64) +{{ $f.IsDir }} → false (bool) +{{ $f.ModTime }} → 2021-11-25 10:06:49.315429236 -0800 PST (time.Time) +{{ $f.Name }} → README.md (string) +{{ $f.Size }} → 241 (int64) {{ $d := os.Stat "content" }} -{{ $d.IsDir }} --> true (bool) +{{ $d.IsDir }} → true (bool) ``` Details of the `FileInfo` structure are available in the [Go documentation](https://pkg.go.dev/io/fs#FileInfo). diff --git a/content/en/functions/readdir.md b/content/en/functions/readdir.md index 9fc4d3013..a76e3c5f6 100644 --- a/content/en/functions/readdir.md +++ b/content/en/functions/readdir.md @@ -26,7 +26,7 @@ This template code: ```go-html-template {{ range os.ReadDir "content" }} - {{ .Name }} --> {{ .IsDir }} + {{ .Name }} → {{ .IsDir }} {{ end }} ``` diff --git a/content/en/functions/replacere.md b/content/en/functions/replacere.md index 22f81a2f5..8c3cc13c2 100644 --- a/content/en/functions/replacere.md +++ b/content/en/functions/replacere.md @@ -13,21 +13,7 @@ relatedfuncs: [findRE, FindRESubmatch, replace] --- By default, `replaceRE` replaces all matches. You can limit the number of matches with an optional LIMIT parameter. -When specifying the regular expression, use a raw [string literal] (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes. - -[string literal]: https://go.dev/ref/spec#String_literals - -This function uses the [RE2] regular expression library. See the [RE2 syntax documentation] for details. Note that the RE2 `\C` escape sequence is not supported. - -[RE2]: https://github.com/google/re2/ -[RE2 syntax documentation]: https://github.com/google/re2/wiki/Syntax/ - -{{% note %}} -The RE2 syntax is a subset of that accepted by [PCRE], roughly speaking, and with various [caveats]. - -[caveats]: https://swtch.com/~rsc/regexp/regexp3.html#caveats -[PCRE]: https://www.pcre.org/ -{{% /note %}} +{{% readfile file="/functions/common/regular-expressions.md" %}} This example replaces two or more consecutive hyphens with a single hyphen: diff --git a/content/en/functions/scratch.md b/content/en/functions/scratch.md index 2e00f41bd..16e502b84 100644 --- a/content/en/functions/scratch.md +++ b/content/en/functions/scratch.md @@ -72,7 +72,7 @@ Get the value of a given key. Add a given value to existing value(s) of the given key. -For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list. +For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be [appended](/functions/append/) to that list. ```go-html-template {{ $scratch.Add "greetings" "Hello" }} diff --git a/content/en/functions/strings.ContainsNonSpace.md b/content/en/functions/strings.ContainsNonSpace.md new file mode 100644 index 000000000..eafe292f5 --- /dev/null +++ b/content/en/functions/strings.ContainsNonSpace.md @@ -0,0 +1,27 @@ +--- +title: strings.ContainsNonSpace +description: Reports whether a string contains any non-space characters as defined by Unicode’s White Space property. +categories: [functions] +menu: + docs: + parent: functions +keywords: [whitespace space] +signature: ["strings.ContainsNonSpace STRING"] +relatedfuncs: ["strings.Contains","strings.ContainsAny"] +--- + +```go-html-template +{{ strings.ContainsNonSpace "\n" }} → false +{{ strings.ContainsNonSpace " " }} → false +{{ strings.ContainsNonSpace "\n abc" }} → true +``` + +Common white space characters include: + +```text +'\t', '\n', '\v', '\f', '\r', ' ' +``` + +See the [Unicode Character Database] for a complete list. + +[Unicode Character Database]: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt diff --git a/content/en/functions/transform.Unmarshal.md b/content/en/functions/transform.Unmarshal.md index ca5433761..7d0920da8 100644 --- a/content/en/functions/transform.Unmarshal.md +++ b/content/en/functions/transform.Unmarshal.md @@ -62,12 +62,12 @@ The following example lists the items of an RSS feed: ```go-html-template {{ with resources.GetRemote "https://example.com/rss.xml" | transform.Unmarshal }} - {{ range .channel.item }} - {{ .title | plainify | htmlUnescape }}
-

{{ .description | plainify | htmlUnescape }}

- {{ $link := .link | plainify | htmlUnescape }} - {{ $link }}
-
- {{ end }} + {{ range .channel.item }} + {{ .title | plainify | htmlUnescape }}
+

{{ .description | plainify | htmlUnescape }}

+ {{ $link := .link | plainify | htmlUnescape }} + {{ $link }}
+
+ {{ end }} {{ end }} ``` diff --git a/content/en/functions/uniq.md b/content/en/functions/uniq.md index 4584ec5ad..aecdccf95 100644 --- a/content/en/functions/uniq.md +++ b/content/en/functions/uniq.md @@ -11,5 +11,5 @@ signature: [uniq SET] ```go-html-template -{{ slice 1 3 2 1 | uniq }} --> [1 3 2] +{{ slice 1 3 2 1 | uniq }} → [1 3 2] ``` diff --git a/content/en/functions/urlize.md b/content/en/functions/urlize.md index 8c9aeb1c3..7a9cf25e8 100644 --- a/content/en/functions/urlize.md +++ b/content/en/functions/urlize.md @@ -22,20 +22,20 @@ The following might be used as a partial within a [single page template][singlet {{< code file="layouts/partials/content-header.html" >}}
-

{{ .Title }}

- {{ with .Params.location }} -
{{ . }}
- {{ end }} - - {{ with .Params.tags }} +

{{ .Title }}

+ {{ with .Params.location }} +
{{ . }}
+ {{ end }} + + {{ with .Params.tags }} - {{ end }} + {{ end }}
{{< /code >}} diff --git a/content/en/functions/where.md b/content/en/functions/where.md index af92619dc..9618ea4c6 100644 --- a/content/en/functions/where.md +++ b/content/en/functions/where.md @@ -73,6 +73,9 @@ The following logical operators are available with `where`: `intersect` : `true` if a given field value that is a slice/array of strings or integers contains elements in common with the matching value; it follows the same rules as the [`intersect` function][intersect]. +`like` +: `true` if a given field value matches a regular expression. Use the `like` operator to compare `string` values. Returns `false` when comparing other data types to the regular expression. + ## Use `where` with boolean values When using booleans you should not put quotation marks. ```go-html-template @@ -80,7 +83,6 @@ When using booleans you should not put quotation marks.

{{ .Title }}

{{ end }} ``` - ## Use `where` with `intersect` @@ -102,6 +104,18 @@ You can also put the returned value of the `where` clauses into a variable: {{ end }} {{< /code >}} +## Use `where` with `like` + +This example matches pages where the "foo" parameter begins with "ab": + +```go-html-template +{{ range where site.RegularPages "Params.foo" "like" `^ab` }} +

{{ .LinkTitle }}

+{{ end }} +``` + +{{% readfile file="/functions/common/regular-expressions.md" %}} + ## Use `where` with `first` Using `first` and `where` together can be very diff --git a/content/en/getting-started/configuration.md b/content/en/getting-started/configuration.md index 91cdebd5b..ea82f1b53 100644 --- a/content/en/getting-started/configuration.md +++ b/content/en/getting-started/configuration.md @@ -168,7 +168,7 @@ Pass down default configuration values (front matter) to pages in the content tr **Default value:** false -Enable to turn relative URLs into absolute. +Enable to turn relative URLs into absolute. See [details](/content-management/urls/#canonical-urls). ### cleanDestinationDir @@ -381,7 +381,7 @@ See [Related Content](/content-management/related/#configure-related-content). **Default value:** false -Enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs. +Enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs. See [details](/content-management/urls/#relative-urls). ### refLinksErrorLevel @@ -517,7 +517,7 @@ The `build` configuration section contains global build-related configuration op buildStats {{< new-in "0.115.1" >}} : When enabled, creates a `hugo_stats.json` file in the root of your project. This file contains arrays of the `class` attributes, `id` attributes, and tags of every HTML element within your published site. Use this file as data source when [removing unused CSS] from your site. This process is also known as pruning, purging, or tree shaking. -[removing unused CSS]: http://localhost:1313/hugo-pipes/postprocess/#css-purging-with-postcss +[removing unused CSS]: /hugo-pipes/postprocess/#css-purging-with-postcss Exclude `class` attributes, `id` attributes, or tags from `hugo_stats.json` with the `disableClasses`, `disableIDs`, and `disableTags` keys. @@ -824,7 +824,7 @@ You can override any of these cache settings in your own `hugo.toml`. ### The keywords explained `:cacheDir` -: This is the value of the `cacheDir` configuration option if set (can also be set via OS env variable `HUGO_CACHEDIR`). It will fall back to `/opt/build/cache/hugo_cache/` on Netlify, or a `hugo_cache_$USER` directory below the OS temp dir for the others. This means that if you run your builds on Netlify, all caches configured with `:cacheDir` will be saved and restored on the next build. For other CI vendors, please read their documentation. For an CircleCI example, see [this configuration](https://github.com/bep/hugo-sass-test/blob/6c3960a8f4b90e8938228688bc49bdcdd6b2d99e/.circleci/config.yml). +: See [Configure cacheDir](#configure-cachedir). `:project` : The base directory name of the current Hugo project. This means that, in its default setting, every project will have separated file caches, which means that when you do `hugo --gc` you will not touch files related to other Hugo projects running on the same PC. @@ -853,3 +853,18 @@ dir [toml]: https://github.com/toml-lang/toml [yaml]: https://yaml.org/spec/ [static-files]: /content-management/static-files/ + + +# Configure cacheDir + +This is the directory where Hugo by default will store its file caches. See [Configure File Caches](#configure-file-caches). + +This can be set using the `cacheDir` config option or via the OS env variable `HUGO_CACHEDIR`. + +If this is not set, Hugo will use, in order of preference: + +1. If running on Netlify: `/opt/build/cache/hugo_cache/`. This means that if you run your builds on Netlify, all caches configured with `:cacheDir` will be saved and restored on the next build. For other CI vendors, please read their documentation. For an CircleCI example, see [this configuration](https://github.com/bep/hugo-sass-test/blob/6c3960a8f4b90e8938228688bc49bdcdd6b2d99e/.circleci/config.yml). +1. In a `hugo_cache` directory below the OS user cache directory as defined by Go's [os.UserCacheDir](https://pkg.go.dev/os#UserCacheDir). On Unix systems, this is `$XDG_CACHE_HOME` as specified by [basedir-spec-latest](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) if non-empty, else `$HOME/.cache`. On MacOS, this is `$HOME/Library/Caches`. On Windows, this is`%LocalAppData%`. On Plan 9, this is `$home/lib/cache`. {{< new-in "0.116.0" >}} +1. In a `hugo_cache_$USER` directory below the OS temp dir. + +If you want to know the current value of `cacheDir`, you can run `hugo config`, e.g: `hugo config | grep cachedir`. diff --git a/content/en/hosting-and-deployment/hosting-on-github/index.md b/content/en/hosting-and-deployment/hosting-on-github/index.md index 47a7074b7..dd8bf5583 100644 --- a/content/en/hosting-and-deployment/hosting-on-github/index.md +++ b/content/en/hosting-and-deployment/hosting-on-github/index.md @@ -100,7 +100,7 @@ jobs: build: runs-on: ubuntu-latest env: - HUGO_VERSION: 0.115.1 + HUGO_VERSION: 0.115.4 steps: - name: Install Hugo CLI run: | diff --git a/content/en/hosting-and-deployment/hosting-on-gitlab.md b/content/en/hosting-and-deployment/hosting-on-gitlab.md index b48a392b7..964e656ed 100644 --- a/content/en/hosting-and-deployment/hosting-on-gitlab.md +++ b/content/en/hosting-and-deployment/hosting-on-gitlab.md @@ -27,8 +27,8 @@ Define your [CI/CD](https://docs.gitlab.com/ee/ci/quick_start/) jobs by creating {{< code file=".gitlab-ci.yml" >}} variables: - DART_SASS_VERSION: 1.63.6 - HUGO_VERSION: 0.115.3 + DART_SASS_VERSION: 1.64.1 + HUGO_VERSION: 0.115.4 NODE_VERSION: 20.x GIT_DEPTH: 0 GIT_STRATEGY: clone @@ -46,8 +46,9 @@ pages: # Install Dart Sass - curl -LJO https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz - tar -xf dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz - - cp -r dart-sass/* /usr/local/bin + - cp -r dart-sass/ /usr/local/bin - rm -rf dart-sass* + - export PATH=/usr/local/bin/dart-sass:$PATH # Install Hugo - curl -LJO https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb - apt-get install -y ./hugo_extended_${HUGO_VERSION}_linux-amd64.deb diff --git a/content/en/hosting-and-deployment/hosting-on-netlify.md b/content/en/hosting-and-deployment/hosting-on-netlify.md index 00cc03042..91d044755 100644 --- a/content/en/hosting-and-deployment/hosting-on-netlify.md +++ b/content/en/hosting-and-deployment/hosting-on-netlify.md @@ -57,14 +57,14 @@ For production: {{< code file="netlify.toml" >}} [context.production.environment] - HUGO_VERSION = "0.99.1" + HUGO_VERSION = "0.115.4" {{< /code >}} For testing: {{< code file="netlify.toml" >}} [context.deploy-preview.environment] - HUGO_VERSION = "0.99.1" + HUGO_VERSION = "0.115.4" {{< /code >}} The Netlify configuration file can be a little hard to understand and get right for the different environment, and you may get some inspiration and tips from this site's `netlify.toml`: diff --git a/content/en/installation/common/05-build-from-source.md b/content/en/installation/common/05-build-from-source.md index c0bd85515..7537882fd 100644 --- a/content/en/installation/common/05-build-from-source.md +++ b/content/en/installation/common/05-build-from-source.md @@ -1,20 +1,23 @@ ## Build from source -To build Hugo from source you must: +To build the extended edition of Hugo from source you must: 1. Install [Git] 1. Install [Go] version 1.19 or later -1. Update your PATH environment variable as described in the [Go documentation] +1. Install a C compiler, either [GCC] or [Clang] +1. Update your `PATH` environment variable as described in the [Go documentation] -> The install directory is controlled by the GOPATH and GOBIN environment variables. If GOBIN is set, binaries are installed to that directory. If GOPATH is set, binaries are installed to the bin subdirectory of the first directory in the GOPATH list. Otherwise, binaries are installed to the bin subdirectory of the default GOPATH ($HOME/go or %USERPROFILE%\go). +> The install directory is controlled by the `GOPATH` and `GOBIN` environment variables. If `GOBIN` is set, binaries are installed to that directory. If `GOPATH` is set, binaries are installed to the bin subdirectory of the first directory in the `GOPATH` list. Otherwise, binaries are installed to the bin subdirectory of the default `GOPATH` (`$HOME/go` or `%USERPROFILE%\go`). Then build and test: ```sh -go install -tags extended github.com/gohugoio/hugo@latest +CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@latest hugo version ``` +[Clang]: https://clang.llvm.org/ +[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 +[Go]: https://go.dev/doc/install diff --git a/content/en/installation/linux.md b/content/en/installation/linux.md index 11c6795f1..4056b987a 100644 --- a/content/en/installation/linux.md +++ b/content/en/installation/linux.md @@ -29,16 +29,18 @@ This will install the extended edition of Hugo: sudo snap install hugo ``` -To enable access to removable media: +To enable or revoke access to removable media: ```sh sudo snap connect hugo:removable-media +sudo snap disconnect hugo:removable-media ``` -To revoke access to removable media: +To enable or revoke access to SSH keys: ```sh -sudo snap disconnect hugo:removable-media +sudo snap connect hugo:ssh-keys +sudo snap disconnect hugo:ssh-keys ``` [most distributions]: https://snapcraft.io/docs/installing-snapd diff --git a/content/en/installation/windows.md b/content/en/installation/windows.md index 9959f590a..92979d9f2 100644 --- a/content/en/installation/windows.md +++ b/content/en/installation/windows.md @@ -52,10 +52,7 @@ winget install Hugo.Hugo.Extended {{% readfile file="/installation/common/05-build-from-source.md" %}} {{% note %}} -When building the extended edition of Hugo from source on Windows, you will also need to install the [GCC compiler]. See these [detailed instructions]. - -[detailed instructions]: https://discourse.gohugo.io/t/41370 -[GCC compiler]: https://gcc.gnu.org/ +See these [detailed instructions](https://discourse.gohugo.io/t/41370) to install GCC on Windows. {{% /note %}} ## Comparison diff --git a/content/en/news/0.25-relnotes/index.md b/content/en/news/0.25-relnotes/index.md index 6ceef445d..5ed0a2bc1 100644 --- a/content/en/news/0.25-relnotes/index.md +++ b/content/en/news/0.25-relnotes/index.md @@ -9,8 +9,6 @@ aliases: [/0-25/] Hugo `0.25` is the **Kinder Surprise**: It automatically opens the page you're working on in the browser, it adds full `AND` and `OR` support in page queries, and you can now have templates per language. -![Hugo Open on Save](https://cdn-standard5.discourse.org/uploads/gohugo/optimized/2X/6/622088d4a8eacaf62bbbaa27dab19d789e10fe09_1_690x345.gif "Hugo Open on Save") - If you start with `hugo server --navigateToChanged`, Hugo will navigate to the relevant page on save (see animated GIF). This is extremely useful for site-wide edits. Another very useful feature in this version is the added support for `AND` (`intersect`) and `OR` (`union`) filters when combined with `where`. Example: diff --git a/content/en/templates/homepage.md b/content/en/templates/homepage.md index 5fe6902d3..a176a51f2 100644 --- a/content/en/templates/homepage.md +++ b/content/en/templates/homepage.md @@ -40,7 +40,7 @@ The following is an example of a homepage template that uses [partial][partials]

{{ .Title }}

{{ with .Params.subtitle }} - {{ . }} + {{ . }} {{ end }}
@@ -49,7 +49,7 @@ The following is an example of a homepage template that uses [partial][partials]
{{ range first 10 .Site.RegularPages }} - {{ .Render "summary" }} + {{ .Render "summary" }} {{ end }}
diff --git a/content/en/templates/internal.md b/content/en/templates/internal.md index 828244fa0..ee0d7258d 100644 --- a/content/en/templates/internal.md +++ b/content/en/templates/internal.md @@ -19,12 +19,12 @@ While the following internal templates are called similar to partials, they do * ## Google Analytics -Hugo ships with internal templates supporting Google Analytics, both [Google Analytics 4][GA4] (GA4) and Universal Analytics. +Hugo ships with an internal template supporting [Google Analytics 4][GA4] (GA4). -**Note:** Universal Analytics are deprecated. For details, see [Universal Analytics will be going away]. +**Note:** Universal Analytics are [deprecated]. [GA4]: https://support.google.com/analytics/answer/10089681 -[Universal Analytics will be going away]: https://support.google.com/analytics/answer/11583528 +[deprecated]: https://support.google.com/analytics/answer/11583528 ### Configure Google Analytics @@ -35,40 +35,29 @@ Provide your tracking ID in your configuration file: googleAnalytics = "G-MEASUREMENT_ID" {{}} -**Google Universal Analytics (analytics.js)** -{{< code-toggle file="hugo" >}} -googleAnalytics = "UA-PROPERTY_ID" -{{}} - ### Use the Google Analytics template -You can then include the Google Analytics internal template: - -```go-html-template -{{ template "_internal/google_analytics_async.html" . }} -``` - -**Note:** The async template is _not_ suitable for Google Analytics 4. +Include the Google Analytics internal template in your templates where you want the code to appear: ```go-html-template {{ template "_internal/google_analytics.html" . }} ``` -If you want to create your own template, you can access the configured ID with `{{ site.Config.Services.GoogleAnalytics.ID }}`. +To create your own template, access the configured ID with `{{ site.Config.Services.GoogleAnalytics.ID }}`. ## Disqus -Hugo also ships with an internal template for [Disqus comments][disqus], a popular commenting system for both static and dynamic websites. In order to effectively use Disqus, you will need to secure a Disqus "shortname" by [signing up for the free service][disqussignup]. +Hugo also ships with an internal template for [Disqus comments][disqus], a popular commenting system for both static and dynamic websites. To effectively use Disqus, secure a Disqus "shortname" by [signing up for the free service][disqussignup]. ### Configure Disqus -To use Hugo's Disqus template, you first need to set a single configuration value: +To use Hugo's Disqus template, first set up a single configuration value: {{< code-toggle file="hugo" >}} disqusShortname = "your-disqus-shortname" {{}} -You also have the option to set the following in the front matter for a given piece of content: +You can also set the following in the front matter for a given piece of content: * `disqus_identifier` * `disqus_title` @@ -76,7 +65,7 @@ You also have the option to set the following in the front matter for a given pi ### Use the Disqus template -To add Disqus, include the following line in templates where you want your comments to appear: +To add Disqus, include the following line in the templates where you want your comments to appear: ```go-html-template {{ template "_internal/disqus.html" . }} @@ -222,7 +211,6 @@ The code for these templates is located [here](https://github.com/gohugoio/hugo/ * `_internal/disqus.html` * `_internal/google_analytics.html` -* `_internal/google_analytics_async.html` * `_internal/opengraph.html` * `_internal/pagination.html` * `_internal/schema.html` diff --git a/content/en/templates/lists/index.md b/content/en/templates/lists/index.md index 204cbcbcc..ec397c32b 100644 --- a/content/en/templates/lists/index.md +++ b/content/en/templates/lists/index.md @@ -166,13 +166,13 @@ This list template has been modified slightly from a template originally used in {{ partial "subheader.html" . }}
-

{{ .Title }}

-
    - - {{ range .Pages }} - {{ .Render "li" }} - {{ end }} -
+

{{ .Title }}

+
    + + {{ range .Pages }} + {{ .Render "li" }} + {{ end }} +
{{ partial "footer.html" . }} @@ -184,10 +184,10 @@ This list template has been modified slightly from a template originally used in {{ define "main" }}
-

{{ .Title }}

- +

{{ .Title }}

+ {{ range .Pages }} - {{ .Render "summary" }} + {{ .Render "summary" }} {{ end }}
diff --git a/content/en/templates/section-templates.md b/content/en/templates/section-templates.md index db8ffd667..55a6c3004 100644 --- a/content/en/templates/section-templates.md +++ b/content/en/templates/section-templates.md @@ -46,17 +46,17 @@ Examples: {{< code file="layouts/_default/section.html" >}} {{ define "main" }}
- {{ .Content }} - - {{ partial "pagination.html" . }} + {{ .Content }} + + {{ partial "pagination.html" . }}
{{ end }} {{< /code >}} diff --git a/content/en/templates/shortcode-templates.md b/content/en/templates/shortcode-templates.md index f293b6d52..6a6700380 100644 --- a/content/en/templates/shortcode-templates.md +++ b/content/en/templates/shortcode-templates.md @@ -94,7 +94,13 @@ most helpful when the condition depends on either of the values, or both: #### `.Inner` -If a closing shortcode is used, the `.Inner` variable will be populated with the content between the opening and closing shortcodes. If a closing shortcode is required, you can check the length of `.Inner` as an indicator of its existence. +If a closing shortcode is used, the `.Inner` variable will be populated with the content between the opening and closing shortcodes. To check if `.Inner` contains anything other than white space: + +```go-html-template +{{ if strings.ContainsNonSpace .Inner }} + Inner is not empty +{{ end }} +``` A shortcode with content declared via the `.Inner` variable can also be declared without the content and without the closing tag by using the self-closing syntax: diff --git a/content/en/templates/single-page-templates.md b/content/en/templates/single-page-templates.md index 861ced99d..12e04db96 100644 --- a/content/en/templates/single-page-templates.md +++ b/content/en/templates/single-page-templates.md @@ -36,10 +36,10 @@ This single page template makes use of Hugo [base templates], the [`.Format` fun