diff options
author | Bjørn Erik Pedersen <[email protected]> | 2022-12-20 11:04:41 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2022-12-20 11:04:41 +0100 |
commit | 9a215d6950e6705f9109497e9f38cc3844172612 (patch) | |
tree | f04e00c7c59f77214ee0c90ab95d5fcab40c25fa /docs/content/en/functions | |
parent | eda1e720cd2434f97d7d931a7ff55447375e8d9a (diff) | |
parent | 41bc6f702aa54200530efbf4267e5c823df3028d (diff) | |
download | hugo-9a215d6950e6705f9109497e9f38cc3844172612.tar.gz hugo-9a215d6950e6705f9109497e9f38cc3844172612.zip |
Merge commit '41bc6f702aa54200530efbf4267e5c823df3028d'
Diffstat (limited to 'docs/content/en/functions')
-rw-r--r-- | docs/content/en/functions/GetPage.md | 2 | ||||
-rw-r--r-- | docs/content/en/functions/after.md | 2 | ||||
-rw-r--r-- | docs/content/en/functions/apply.md | 6 | ||||
-rw-r--r-- | docs/content/en/functions/format.md | 2 | ||||
-rw-r--r-- | docs/content/en/functions/len.md | 8 | ||||
-rw-r--r-- | docs/content/en/functions/markdownify.md | 2 | ||||
-rw-r--r-- | docs/content/en/functions/param.md | 4 | ||||
-rw-r--r-- | docs/content/en/functions/partialCached.md | 2 | ||||
-rw-r--r-- | docs/content/en/functions/render.md | 2 | ||||
-rw-r--r-- | docs/content/en/functions/safeURL.md | 2 | ||||
-rw-r--r-- | docs/content/en/functions/seq.md | 2 | ||||
-rw-r--r-- | docs/content/en/functions/slice.md | 2 | ||||
-rw-r--r-- | docs/content/en/functions/time.md | 2 |
13 files changed, 20 insertions, 18 deletions
diff --git a/docs/content/en/functions/GetPage.md b/docs/content/en/functions/GetPage.md index 0c74e628b..6a6262f75 100644 --- a/docs/content/en/functions/GetPage.md +++ b/docs/content/en/functions/GetPage.md @@ -56,7 +56,7 @@ The previous examples have used the full content filename to look up the post. D This code snippet---in the form of a [partial template][partials]---allows you to do the following: -1. Grab the index object of your `tags` [taxonomy][]. +1. Grab the index object of your `tags` [taxonomy]. 2. Assign this object to a variable, `$t` 3. Sort the terms associated with the taxonomy by popularity. 4. Grab the top two most popular terms in the taxonomy (i.e., the two most popular tags assigned to content. diff --git a/docs/content/en/functions/after.md b/docs/content/en/functions/after.md index da93b3e44..1d513e775 100644 --- a/docs/content/en/functions/after.md +++ b/docs/content/en/functions/after.md @@ -29,7 +29,7 @@ The following shows `after` being used in conjunction with the [`slice` function ## Example of `after` with `first`: 2nd–4th Most Recent Articles -You can use `after` in combination with the [`first` function][] and Hugo's [powerful sorting methods][lists]. Let's assume you have a list page at `example.com/articles`. You have 10 articles, but you want your templating for the [list/section page][] to show only two rows: +You can use `after` in combination with the [`first` function] and Hugo's [powerful sorting methods][lists]. Let's assume you have a list page at `example.com/articles`. You have 10 articles, but you want your templating for the [list/section page] to show only two rows: 1. The top row is titled "Featured" and shows only the most recently published article (i.e. by `publishdate` in the content files' front matter). 2. The second row is titled "Recent Articles" and shows only the 2nd- to 4th-most recently published articles. diff --git a/docs/content/en/functions/apply.md b/docs/content/en/functions/apply.md index 7550069a5..983e2fdb9 100644 --- a/docs/content/en/functions/apply.md +++ b/docs/content/en/functions/apply.md @@ -48,7 +48,7 @@ Which will result in the following: "derek-perkins", "joe-bergevin", "tanner-linsley" ``` -This is *roughly* equivalent to using the following with [range][]: +This is *roughly* equivalent to using the following with [range]: ``` {{ range .Params.names }}{{ . | urlize }}{{ end }} @@ -56,7 +56,7 @@ This is *roughly* equivalent to using the following with [range][]: However, it is not possible to provide the output of a range to the [`delimit` function][delimit], so you need to `apply` it. -If you have `post-tag-list.html` and `post-tag-link.html` as [partials][], you *could* use the following snippets, respectively: +If you have `post-tag-list.html` and `post-tag-link.html` as [partials], you *could* use the following snippets, respectively: {{< code file="layouts/partials/post-tag-list.html" copy="false" >}} {{ with .Params.tags }} @@ -96,7 +96,7 @@ This first version of `layouts/partials/post-tag-list.html` separates all of the {{ end }} ``` -Now in the completed version, you can sort the tags, convert the tags to links with `layouts/partials/post-tag-link.html`, [chomp][] off stray newlines, and join the tags together in a delimited list for presentation. Here is an even DRYer version of the preceding example: +Now in the completed version, you can sort the tags, convert the tags to links with `layouts/partials/post-tag-link.html`, [chomp] off stray newlines, and join the tags together in a delimited list for presentation. Here is an even DRYer version of the preceding example: {{< code file="layouts/partials/post-tag-list.html" download="post-tag-list.html" >}} {{ with .Params.tags }} diff --git a/docs/content/en/functions/format.md b/docs/content/en/functions/format.md index 4ef806f45..e2f93f1fc 100644 --- a/docs/content/en/functions/format.md +++ b/docs/content/en/functions/format.md @@ -53,7 +53,7 @@ Here is a visual explanation [taken directly from the Go docs][gdex]: The following examples show the layout string followed by the rendered output. -The examples were rendered and tested in [CST][] and all point to the same field in a content file's front matter: +The examples were rendered and tested in [CST] and all point to the same field in a content file's front matter: ``` date: 2017-03-03T14:15:59-06:00 diff --git a/docs/content/en/functions/len.md b/docs/content/en/functions/len.md index 0681583db..9f15d79c7 100644 --- a/docs/content/en/functions/len.md +++ b/docs/content/en/functions/len.md @@ -31,7 +31,7 @@ aliases: [] > > Channel: the number of elements queued (unread) in the channel buffer; if v is nil, len(v) is zero. -`len` is also considered a [fundamental function for Hugo templating][]. +`len` is also considered a [fundamental function for Hugo templating]. ## `len` Example 1: Longer Headings @@ -45,15 +45,15 @@ You may want to append a class to a heading according to the length of the strin ## `len` Example 2: Counting Pages with `where` -The following templating uses [`where`][] in conjunction with `len` to -figure out the total number of content pages in a `posts` [section][]: +The following templating uses [`where`] in conjunction with `len` to +figure out the total number of content pages in a `posts` [section]: {{< code file="how-many-posts.html" >}} {{ $posts := (where .Site.RegularPages "Section" "==" "posts") }} {{ $postCount := len $posts }} {{< /code >}} -Note the use of `.RegularPages`, a [site variable][] that counts all regular content pages but not the `_index.md` pages used to add front matter and content to [list templates][]. +Note the use of `.RegularPages`, a [site variable] that counts all regular content pages but not the `_index.md` pages used to add front matter and content to [list templates]. [fundamental function for Hugo templating]: /templates/introduction/ diff --git a/docs/content/en/functions/markdownify.md b/docs/content/en/functions/markdownify.md index b108ccb94..b42e045e7 100644 --- a/docs/content/en/functions/markdownify.md +++ b/docs/content/en/functions/markdownify.md @@ -23,6 +23,6 @@ aliases: [] {{ .Title | markdownify }} ``` -{{< new-in "0.93.0" >}} **Note**: `markdownify` now supports [Render Hooks][] just like [.RenderString](/functions/renderstring/). +{{< new-in "0.93.0" >}} **Note**: `markdownify` now supports [Render Hooks] just like [.RenderString](/functions/renderstring/). [Render Hooks]: /templates/render-hooks/ diff --git a/docs/content/en/functions/param.md b/docs/content/en/functions/param.md index eb0a87279..5387647d2 100644 --- a/docs/content/en/functions/param.md +++ b/docs/content/en/functions/param.md @@ -19,11 +19,11 @@ draft: false aliases: [] --- -In Hugo, you can declare [site-wide params][sitevars] (i.e. in your [configuration][]), as well as params for [individual pages][pagevars]. +In Hugo, you can declare [site-wide params][sitevars] (i.e. in your [configuration]), as well as params for [individual pages][pagevars]. A common use case is to have a general value for the site and a more specific value for some of the pages (e.g., an image). -You can use the `.Param` method to call these values into your template. The following will first look for an `image` param in a specific content's [front matter][]. If not found, Hugo will look for an `image` param in your site's configuration: +You can use the `.Param` method to call these values into your template. The following will first look for an `image` param in a specific content's [front matter]. If not found, Hugo will look for an `image` param in your site's configuration: ``` $.Param "image" diff --git a/docs/content/en/functions/partialCached.md b/docs/content/en/functions/partialCached.md index a0c317377..2e79bb32f 100644 --- a/docs/content/en/functions/partialCached.md +++ b/docs/content/en/functions/partialCached.md @@ -22,6 +22,8 @@ The `partialCached` template function can offer significant performance gains fo **Note:** Each Site (or language) has its own `partialCached` cache, so each site will execute a partial once. +**Note**: 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: ``` diff --git a/docs/content/en/functions/render.md b/docs/content/en/functions/render.md index c2347091f..7e4015bf6 100644 --- a/docs/content/en/functions/render.md +++ b/docs/content/en/functions/render.md @@ -19,7 +19,7 @@ aliases: [] The view is an alternative layout and should be a file name that points to a template in one of the locations specified in the documentation for [Content Views](/templates/views). -This function is only available when applied to a single piece of content within a [list context][]. +This function is only available when applied to a single piece of content within a [list context]. This example could render a piece of content using the content view located at `/layouts/_default/summary.html`: diff --git a/docs/content/en/functions/safeURL.md b/docs/content/en/functions/safeURL.md index 959076246..285542ea9 100644 --- a/docs/content/en/functions/safeURL.md +++ b/docs/content/en/functions/safeURL.md @@ -17,7 +17,7 @@ deprecated: false aliases: [] --- -`safeURL` declares the provided string as a "safe" URL or URL substring (see [RFC 3986][]). A URL like `javascript:checkThatFormNotEditedBeforeLeavingPage()` from a trusted source should go in the page, but by default dynamic `javascript:` URLs are filtered out since they are a frequently exploited injection vector. +`safeURL` declares the provided string as a "safe" URL or URL substring (see [RFC 3986]). A URL like `javascript:checkThatFormNotEditedBeforeLeavingPage()` from a trusted source should go in the page, but by default dynamic `javascript:` URLs are filtered out since they are a frequently exploited injection vector. Without `safeURL`, only the URI schemes `http:`, `https:` and `mailto:` are considered safe by Go templates. If any other URI schemes (e.g., `irc:` and `javascript:`) are detected, the whole URL will be replaced with `#ZgotmplZ`. This is to "defang" any potential attack in the URL by rendering it useless. diff --git a/docs/content/en/functions/seq.md b/docs/content/en/functions/seq.md index c0750b4a1..a880ec241 100644 --- a/docs/content/en/functions/seq.md +++ b/docs/content/en/functions/seq.md @@ -19,7 +19,7 @@ draft: false aliases: [] --- -It's named and used in the model of [GNU's seq][]. +It's named and used in the model of [GNU's seq]. ``` 3 → 1, 2, 3 diff --git a/docs/content/en/functions/slice.md b/docs/content/en/functions/slice.md index 24b717128..9b5580d44 100644 --- a/docs/content/en/functions/slice.md +++ b/docs/content/en/functions/slice.md @@ -20,7 +20,7 @@ aliases: [] toc: false --- -One use case is the concatenation of elements in combination with the [`delimit` function][]: +One use case is the concatenation of elements in combination with the [`delimit` function]: {{< code file="slice.html" >}} {{ $sliceOfStrings := slice "foo" "bar" "buzz" }} diff --git a/docs/content/en/functions/time.md b/docs/content/en/functions/time.md index 681c85fd9..175e2dbfe 100644 --- a/docs/content/en/functions/time.md +++ b/docs/content/en/functions/time.md @@ -43,7 +43,7 @@ If no `TIMEZONE` is set, the `timeZone` from site configuration will be used. ## Example: Using `time` to get Month Index -The following example takes a UNIX timestamp---set as `utimestamp: "1489276800"` in a content's front matter---converts the timestamp (string) to an integer using the [`int` function][int], and then uses [`printf`][] to convert the `Month` property of `time` into an index. +The following example takes a UNIX timestamp---set as `utimestamp: "1489276800"` in a content's front matter---converts the timestamp (string) to an integer using the [`int` function][int], and then uses [`printf`] to convert the `Month` property of `time` into an index. The following example may be useful when setting up [multilingual sites][multilingual]: |