mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-15 13:04:46 -04:00
Miscellaneous edits
This commit is contained in:
parent
2cbe17f418
commit
8cd6ac3874
@ -10,11 +10,11 @@ signature: ["apply COLLECTION FUNCTION [PARAM...]"]
|
|||||||
relatedfuncs: []
|
relatedfuncs: []
|
||||||
---
|
---
|
||||||
|
|
||||||
`apply` expects at least three parameters, depending on the function being applied.
|
`apply` expects at least three arguments, depending on the function being applied.
|
||||||
|
|
||||||
1. The first parameter is the sequence to operate on.
|
1. The first argument is the sequence to operate on.
|
||||||
2. The second parameter is the name of the function as a string, which must be the name of a valid [Hugo function][functions].
|
2. The second argument is the name of the function as a string, which must be the name of a valid [Hugo function][functions].
|
||||||
3. After that, the parameters to the applied function are provided, with the string `"."` standing in for each element of the sequence the function is to be applied against.
|
3. After that, the arguments to the applied function are provided, with the string `"."` standing in for each element of the sequence the function is to be applied against.
|
||||||
|
|
||||||
Here is an example of a content file with `names:` as a front matter field:
|
Here is an example of a content file with `names:` as a front matter field:
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ signature:
|
|||||||
- "strings.FindRE PATTERN INPUT [LIMIT]"
|
- "strings.FindRE PATTERN INPUT [LIMIT]"
|
||||||
relatedfuncs: [findRESubmatch, replaceRE]
|
relatedfuncs: [findRESubmatch, replaceRE]
|
||||||
---
|
---
|
||||||
By default, `findRE` finds all matches. You can limit the number of matches with an optional LIMIT parameter.
|
By default, `findRE` finds all matches. You can limit the number of matches with an optional LIMIT argument.
|
||||||
|
|
||||||
{{% readfile file="/functions/common/regular-expressions.md" %}}
|
{{% readfile file="/functions/common/regular-expressions.md" %}}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ signature:
|
|||||||
relatedfuncs: [findRE, replaceRE]
|
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.
|
By default, `findRESubmatch` finds all matches. You can limit the number of matches with an optional LIMIT argument. A return value of nil indicates no match.
|
||||||
|
|
||||||
{{% readfile file="/functions/common/regular-expressions.md" %}}
|
{{% readfile file="/functions/common/regular-expressions.md" %}}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ toc: true
|
|||||||
---
|
---
|
||||||
The `highlight` function uses the [Chroma] syntax highlighter, supporting over 200 languages with more than 40 available styles.
|
The `highlight` function uses the [Chroma] syntax highlighter, supporting over 200 languages with more than 40 available styles.
|
||||||
|
|
||||||
## Parameters
|
## Arguments
|
||||||
|
|
||||||
INPUT
|
INPUT
|
||||||
: The code to highlight.
|
: The code to highlight.
|
||||||
@ -67,7 +67,7 @@ Substitute this number of spaces for each tab character in your highlighted code
|
|||||||
|
|
||||||
guessSyntax
|
guessSyntax
|
||||||
: Boolean. Default is `false`.\
|
: Boolean. Default is `false`.\
|
||||||
If the `LANG` parameter is blank or an unrecognized language, auto-detect the language if possible, otherwise use a fallback language.
|
If the `LANG` argument is blank or an unrecognized language, auto-detect the language if possible, otherwise use a fallback language.
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
Instead of specifying both `lineNos` and `lineNumbersInTable`, you can use the following shorthand notation:
|
Instead of specifying both `lineNos` and `lineNumbersInTable`, you can use the following shorthand notation:
|
||||||
|
@ -68,7 +68,7 @@ location = "oslo"
|
|||||||
|
|
||||||
The content of `oslo.toml` can be accessed from your template using the following node path: `.Site.Data.locations.oslo`. However, the specific file you need is going to change according to the front matter.
|
The content of `oslo.toml` can be accessed from your template using the following node path: `.Site.Data.locations.oslo`. However, the specific file you need is going to change according to the front matter.
|
||||||
|
|
||||||
This is where the `index` function is needed. `index` takes 2 parameters in this use case:
|
This is where the `index` function is needed. `index` takes 2 arguments in this use case:
|
||||||
|
|
||||||
1. The node path
|
1. The node path
|
||||||
2. A string corresponding to the desired data; e.g.—
|
2. A string corresponding to the desired data; e.g.—
|
||||||
|
@ -22,18 +22,18 @@ Here is the simplest usage:
|
|||||||
{{ partialCached "footer.html" . }}
|
{{ partialCached "footer.html" . }}
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also pass additional parameters to `partialCached` to create *variants* of the cached partial. For example, if you have a complex partial that should be identical when rendered for pages within the same section, you could use a variant based upon section so that the partial is only rendered once per section:
|
You can also pass additional arguments to `partialCached` to create *variants* of the cached partial. For example, if you have a complex partial that should be identical when rendered for pages within the same section, you could use a variant based upon section so that the partial is only rendered once per section:
|
||||||
|
|
||||||
{{< code file="partial-cached-example.html" >}}
|
{{< code file="partial-cached-example.html" >}}
|
||||||
{{ partialCached "footer.html" . .Section }}
|
{{ partialCached "footer.html" . .Section }}
|
||||||
{{< /code >}}
|
{{< /code >}}
|
||||||
|
|
||||||
If you need to pass additional parameters to create unique variants, you can pass as many variant parameters as you need:
|
If you need to pass additional arguments to create unique variants, you can pass as many variant arguments as you need:
|
||||||
|
|
||||||
```go-html-template
|
```go-html-template
|
||||||
{{ partialCached "footer.html" . .Params.country .Params.province }}
|
{{ partialCached "footer.html" . .Params.country .Params.province }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the variant parameters are not made available to the underlying partial template. They are only use to create a unique cache key. Since Hugo `0.61.0` you can use any object as cache key(s), not just strings.
|
Note that the variant arguments are not made available to the underlying partial template. They are only use to create a unique cache key. Since Hugo `0.61.0` you can use any object as cache key(s), not just strings.
|
||||||
|
|
||||||
See also [The Full Partial Series Part 1: Caching!](https://regisphilibert.com/blog/2019/12/hugo-partial-series-part-1-caching-with-partialcached/).
|
See also [The Full Partial Series Part 1: Caching!](https://regisphilibert.com/blog/2019/12/hugo-partial-series-part-1-caching-with-partialcached/).
|
||||||
|
@ -10,7 +10,7 @@ signature: ["ref . PAGE"]
|
|||||||
relatedfuncs: [relref]
|
relatedfuncs: [relref]
|
||||||
---
|
---
|
||||||
|
|
||||||
This function takes two parameters:
|
This function takes two arguments:
|
||||||
|
|
||||||
- The context of the page from which to resolve relative paths, typically the current page (`.`)
|
- The context of the page from which to resolve relative paths, typically the current page (`.`)
|
||||||
- The path to a page, with or without a file extension, with or without an anchor. A path without a leading `/` is first resolved relative to the given context, then to the remainder of the site.
|
- The path to a page, with or without a file extension, with or without an anchor. A path without a leading `/` is first resolved relative to the given context, then to the remainder of the site.
|
||||||
|
@ -10,7 +10,7 @@ signature: ["relref . PAGE"]
|
|||||||
relatedfuncs: [ref]
|
relatedfuncs: [ref]
|
||||||
---
|
---
|
||||||
|
|
||||||
This function takes two parameters:
|
This function takes two arguments:
|
||||||
|
|
||||||
- The context of the page from which to resolve relative paths, typically the current page (`.`)
|
- The context of the page from which to resolve relative paths, typically the current page (`.`)
|
||||||
- The path to a page, with or without a file extension, with or without an anchor. A path without a leading `/` is first resolved relative to the given context, then to the remainder of the site.
|
- The path to a page, with or without a file extension, with or without an anchor. A path without a leading `/` is first resolved relative to the given context, then to the remainder of the site.
|
||||||
|
@ -13,7 +13,7 @@ relatedfuncs: [replaceRE]
|
|||||||
---
|
---
|
||||||
|
|
||||||
Replace returns a copy of `INPUT` with all occurrences of `OLD` replaced with `NEW`.
|
Replace returns a copy of `INPUT` with all occurrences of `OLD` replaced with `NEW`.
|
||||||
The number of replacements can be limited with an optional `LIMIT` parameter.
|
The number of replacements can be limited with an optional `LIMIT` argument.
|
||||||
|
|
||||||
```
|
```
|
||||||
`{{ replace "Batman and Robin" "Robin" "Catwoman" }}`
|
`{{ replace "Batman and Robin" "Robin" "Catwoman" }}`
|
||||||
|
@ -11,7 +11,7 @@ signature:
|
|||||||
- "strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]"
|
- "strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]"
|
||||||
relatedfuncs: [findRE, FindRESubmatch, replace]
|
relatedfuncs: [findRE, FindRESubmatch, replace]
|
||||||
---
|
---
|
||||||
By default, `replaceRE` replaces all matches. You can limit the number of matches with an optional LIMIT parameter.
|
By default, `replaceRE` replaces all matches. You can limit the number of matches with an optional LIMIT argument.
|
||||||
|
|
||||||
{{% readfile file="/functions/common/regular-expressions.md" %}}
|
{{% readfile file="/functions/common/regular-expressions.md" %}}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ signature:
|
|||||||
relatedfuncs: []
|
relatedfuncs: []
|
||||||
---
|
---
|
||||||
|
|
||||||
It normally takes two parameters: `start` and `length`. It can also take one parameter: `start`, i.e. `length` is omitted, in which case the substring starting from start until the end of the string will be returned.
|
It normally takes two argument: `start` and `length`. It can also take one argument: `start`, i.e. `length` is omitted, in which case the substring starting from start until the end of the string will be returned.
|
||||||
|
|
||||||
To extract characters from the end of the string, use a negative start number.
|
To extract characters from the end of the string, use a negative start number.
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ relatedfuncs: []
|
|||||||
|
|
||||||
## Using locations
|
## Using locations
|
||||||
|
|
||||||
The optional `TIMEZONE` parameter is a string that sets a default time zone (or more specific, the location, which represents the collection of time offsets in a geographical area) that is associated with the specified time value. If the time value has an explicit timezone or offset specified, it will take precedence over the `TIMEZONE` parameter.
|
The optional `TIMEZONE` argument is a string that sets a default time zone (or more specific, the location, which represents the collection of time offsets in a geographical area) that is associated with the specified time value. If the time value has an explicit timezone or offset specified, it will take precedence over the `TIMEZONE` argument.
|
||||||
|
|
||||||
The list of valid locations may be system dependent, but should include `UTC`, `Local`, or any location in the [IANA Time Zone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
The list of valid locations may be system dependent, but should include `UTC`, `Local`, or any location in the [IANA Time Zone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ The **Let’s Encrypt website** has a common set of elements: A landing page and
|
|||||||
|
|
||||||
I helped them port the site from Jekyll to Hugo. There are usually very few surprises doing this. I know Hugo very well, but working on sites with a history usually comes up with something new.
|
I helped them port the site from Jekyll to Hugo. There are usually very few surprises doing this. I know Hugo very well, but working on sites with a history usually comes up with something new.
|
||||||
|
|
||||||
That site is bookmarked in many browsers, so preserving the URLs was a must. Hugo's URL handling is very flexible, but there was one challenge. The website has a mix of standard and what we in Hugo call _ugly URLs_ (`https://letsencrypt.org/2017/12/07/looking-forward-to-2018.html`). In Hugo this is handled automatically, and you can turn it on globally or per language. But before Hugo `0.33` you could not configure it for parts of your site. You could set it manually for the relevant pages in front matter -- which is how it was done in Jekyll -- but that would be hard to manage, especially when you start to introduce translations. So, in [Hugo 0.33](/news/0.33-relnotes) I added support for _ugly URLs_ per section and also `url` set in front matter for list pages (`https://letsencrypt.org/blog/`).
|
That site is bookmarked in many browsers, so preserving the URLs was a must. Hugo's URL handling is very flexible, but there was one challenge. The website has a mix of standard and what we in Hugo call _ugly URLs_ (`https://letsencrypt.org/2017/12/07/looking-forward-to-2018.html`). In Hugo this is handled automatically, and you can turn it on globally or per language. But before Hugo `0.33` you could not configure it for parts of your site. You could set it manually for the relevant pages in front matter -- which is how it was done in Jekyll -- but that would be hard to manage, especially when you start to introduce translations. So, in Hugo 0.33 I added support for _ugly URLs_ per section and also `url` set in front matter for list pages (`https://letsencrypt.org/blog/`).
|
||||||
|
|
||||||
The lessons learned from this also lead to [disableLanguages](/content-management/multilingual/#disable-a-language) in Hugo `0.34` (a way to turn off languages during translation). And I also registered [this issue](https://github.com/gohugoio/hugo/issues/4463). Once fixed it will make it easier to handle partially translated sites.
|
The lessons learned from this also lead to [disableLanguages](/content-management/multilingual/#disable-a-language) in Hugo `0.34` (a way to turn off languages during translation). And I also registered [this issue](https://github.com/gohugoio/hugo/issues/4463). Once fixed it will make it easier to handle partially translated sites.
|
||||||
|
|
||||||
|
@ -128,29 +128,11 @@ Value: {{ partial "my-inline-partial.html" . }}
|
|||||||
|
|
||||||
## Cached partials
|
## Cached partials
|
||||||
|
|
||||||
The [`partialCached` template function][partialcached] can offer significant performance gains for complex templates that don't need to be re-rendered on every invocation. The simplest usage is as follows:
|
The `partialCached` template function provides significant performance gains for complex templates that don't need to be re-rendered on every invocation. See [details][partialcached].
|
||||||
|
|
||||||
```go-html-template
|
## Examples
|
||||||
{{ partialCached "footer.html" . }}
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also pass additional parameters to `partialCached` to create *variants* of the cached partial.
|
### `header.html`
|
||||||
|
|
||||||
For example, you can tell Hugo to only render the partial `footer.html` once per section:
|
|
||||||
|
|
||||||
```go-html-template
|
|
||||||
{{ partialCached "footer.html" . .Section }}
|
|
||||||
```
|
|
||||||
|
|
||||||
If you need to pass additional parameters to create unique variants, you can pass as many variant parameters as you need:
|
|
||||||
|
|
||||||
```go-html-template
|
|
||||||
{{ partialCached "footer.html" . .Params.country .Params.province }}
|
|
||||||
```
|
|
||||||
|
|
||||||
Note that the variant parameters are not made available to the underlying partial template. They are only use to create a unique cache key.
|
|
||||||
|
|
||||||
### Example `header.html`
|
|
||||||
|
|
||||||
The following `header.html` partial template is used for [spf13.com](https://spf13.com/):
|
The following `header.html` partial template is used for [spf13.com](https://spf13.com/):
|
||||||
|
|
||||||
@ -175,7 +157,7 @@ The following `header.html` partial template is used for [spf13.com](https://spf
|
|||||||
The `header.html` example partial was built before the introduction of block templates to Hugo. Read more on [base templates and blocks](/templates/base/) for defining the outer chrome or shell of your master templates (i.e., your site's head, header, and footer). You can even combine blocks and partials for added flexibility.
|
The `header.html` example partial was built before the introduction of block templates to Hugo. Read more on [base templates and blocks](/templates/base/) for defining the outer chrome or shell of your master templates (i.e., your site's head, header, and footer). You can even combine blocks and partials for added flexibility.
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
### Example `footer.html`
|
### `footer.html`
|
||||||
|
|
||||||
The following `footer.html` partial template is used for [spf13.com](https://spf13.com/):
|
The following `footer.html` partial template is used for [spf13.com](https://spf13.com/):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user