Skip to content

Commit

Permalink
Miscellaneous edits
Browse files Browse the repository at this point in the history
  • Loading branch information
jmooring committed Aug 12, 2023
1 parent 2cbe17f commit 8cd6ac3
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 41 deletions.
8 changes: 4 additions & 4 deletions content/en/functions/apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ signature: ["apply COLLECTION FUNCTION [PARAM...]"]
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.
2. The second parameter 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.
1. The first argument is the sequence to operate on.
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 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:

Expand Down
2 changes: 1 addition & 1 deletion content/en/functions/findRe.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ signature:
- "strings.FindRE PATTERN INPUT [LIMIT]"
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" %}}

Expand Down
2 changes: 1 addition & 1 deletion content/en/functions/findresubmatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ signature:
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" %}}

Expand Down
4 changes: 2 additions & 2 deletions content/en/functions/highlight.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ toc: true
---
The `highlight` function uses the [Chroma] syntax highlighter, supporting over 200 languages with more than 40 available styles.

## Parameters
## Arguments

INPUT
: The code to highlight.
Expand Down Expand Up @@ -67,7 +67,7 @@ Substitute this number of spaces for each tab character in your highlighted code

guessSyntax
: 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 %}}
Instead of specifying both `lineNos` and `lineNumbersInTable`, you can use the following shorthand notation:
Expand Down
2 changes: 1 addition & 1 deletion content/en/functions/index-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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
2. A string corresponding to the desired data; e.g.—
Expand Down
6 changes: 3 additions & 3 deletions content/en/functions/partialCached.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ Here is the simplest usage:
{{ 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" >}}
{{ partialCached "footer.html" . .Section }}
{{< /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
{{ 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/).
2 changes: 1 addition & 1 deletion content/en/functions/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ signature: ["ref . PAGE"]
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 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.
Expand Down
2 changes: 1 addition & 1 deletion content/en/functions/relref.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ signature: ["relref . PAGE"]
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 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.
Expand Down
2 changes: 1 addition & 1 deletion content/en/functions/replace.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ relatedfuncs: [replaceRE]
---

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" }}`
Expand Down
2 changes: 1 addition & 1 deletion content/en/functions/replacere.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ signature:
- "strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]"
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" %}}

Expand Down
2 changes: 1 addition & 1 deletion content/en/functions/substr.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ signature:
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.

Expand Down
2 changes: 1 addition & 1 deletion content/en/functions/time.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ relatedfuncs: []

## 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).

Expand Down
2 changes: 1 addition & 1 deletion content/en/showcase/letsencrypt/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.

Expand Down
26 changes: 4 additions & 22 deletions content/en/templates/partials.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,29 +128,11 @@ Value: {{ partial "my-inline-partial.html" . }}

## 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
{{ partialCached "footer.html" . }}
```

You can also pass additional parameters to `partialCached` to create *variants* of the cached partial.

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.
## Examples

### Example `header.html`
### `header.html`

The following `header.html` partial template is used for [spf13.com](https://spf13.com/):

Expand All @@ -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.
{{% /note %}}

### Example `footer.html`
### `footer.html`

The following `footer.html` partial template is used for [spf13.com](https://spf13.com/):

Expand Down

0 comments on commit 8cd6ac3

Please sign in to comment.