Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure consistent use of method instead of variable #2627

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/en/content-management/cross-references.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The `ref` and `relref` shortcodes display the absolute and relative permalinks t

## Use of `ref` and `relref`

The `ref` and `relref` shortcodes require a single parameter: the path to a content document, with or without a file extension, with or without an anchor. Paths without a leading `/` are first resolved relative to the current page, then to the remainder of the site.
The `ref` and `relref` shortcodes require a single argument: the path to a content document, with or without a file extension, with or without an anchor. Paths without a leading `/` are first resolved relative to the current page, then to the remainder of the site.

```text
.
Expand Down
2 changes: 1 addition & 1 deletion content/en/content-management/data-sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Use data sources to augment existing content. For example, create a shortcode to
{{ errorf "The %q shortcode was unable to find %s. See %s" $.Name $file $.Position }}
{{ end }}
{{ else }}
{{ errorf "The %q shortcode requires one positional parameter, the path to the CSV file relative to the assets directory. See %s" .Name .Position }}
{{ errorf "The %q shortcode requires one positional argument, the path to the CSV file relative to the assets directory. See %s" .Name .Position }}
{{ end }}
{{< /code >}}

Expand Down
18 changes: 9 additions & 9 deletions content/en/content-management/shortcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ In addition to cleaner Markdown, shortcodes can be updated any time to reflect n

{{< youtube 2xkNJL4gJ9E >}}

In your content files, a shortcode can be called by calling `{{%/* shortcodename parameters */%}}`. Shortcode parameters are space delimited, and parameters with internal spaces can be quoted.
In your content files, a shortcode can be called by calling `{{%/* shortcodename arguments */%}}`. Shortcode arguments are space delimited, and arguments with internal spaces must be quoted.

The first word in the shortcode declaration is always the name of the shortcode. Parameters follow the name. Depending upon how the shortcode is defined, the parameters may be named, positional, or both, although you can't mix parameter types in a single call. The format for named parameters models that of HTML with the format `name="value"`.
The first word in the shortcode declaration is always the name of the shortcode. Arguments follow the name. Depending upon how the shortcode is defined, the arguments may be named, positional, or both, although you can't mix argument types in a single call. The format for named arguments models that of HTML with the format `name="value"`.

Some shortcodes use or require closing shortcodes. Again like HTML, the opening and closing shortcodes match (name only) with the closing declaration, which is prepended with a slash.

Expand All @@ -45,9 +45,9 @@ Here are two examples of paired shortcodes:

The examples above use two different delimiters, the difference being the `%` character in the first and the `<>` characters in the second.

### Shortcodes with raw string parameters
### Shortcodes with raw string arguments

You can pass multiple lines as parameters to a shortcode by using raw string literals:
You can pass multiple lines as arguments to a shortcode by using raw string literals:

```go-html-template
{{</* myshortcode `This is some <b>HTML</b>,
Expand Down Expand Up @@ -82,7 +82,7 @@ To override Hugo's embedded `figure` shortcode, copy the [source code] to a file
[source code]: {{% eturl figure %}}
{{% /note %}}

The `figure` shortcode can use the following named parameters:
The `figure` shortcode can use the following named arguments:

src
: URL of the image to be displayed.
Expand All @@ -91,10 +91,10 @@ link
: If the image needs to be hyperlinked, URL of the destination.

target
: Optional `target` attribute for the URL if `link` parameter is set.
: Optional `target` attribute for the URL if `link` argument is set.

rel
: Optional `rel` attribute for the URL if `link` parameter is set.
: Optional `rel` attribute for the URL if `link` argument is set.

alt
: Alternate text for the image if the image cannot be displayed.
Expand Down Expand Up @@ -380,7 +380,7 @@ Rendered:
{{< vimeo 55073825 >}}

{{% note %}}
If you want to further customize the visual styling, add a `class` parameter when calling the shortcode. The new `class` will be added to the `<div>` that wraps the `<iframe>` *and* will remove the inline styles. Note that you will need to call the `id` as a named parameter as well. You can also give the vimeo video a descriptive title with `title`.
If you want to further customize the visual styling, add a `class` argument when calling the shortcode. The new `class` will be added to the `<div>` that wraps the `<iframe>` *and* will remove the inline styles. Note that you will need to call the `id` as a named argument as well. You can also give the vimeo video a descriptive title with `title`.

```go
{{</* vimeo id="146022717" class="my-vimeo-wrapper-class" title="My vimeo video" */>}}
Expand Down Expand Up @@ -411,7 +411,7 @@ Rendered:

{{< youtube 0RKpf3rK57I >}}

The youtube shortcode accepts these named parameters:
The youtube shortcode accepts these named arguments:

id
: (`string`) The video `id`. Optional if the `id` is provided as a positional argument as shown in the example above.
Expand Down
2 changes: 1 addition & 1 deletion content/en/content-management/syntax-highlighting.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Run `hugo gen chromastyles -h` for more options. See https://xyproto.github.io/s

## Highlight shortcode

Highlighting is carried out via the built-in [`highlight` shortcode](/content-management/shortcodes/#highlight). It takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode.
Highlighting is carried out via the built-in [`highlight` shortcode](/content-management/shortcodes/#highlight). It takes exactly one required argument for the programming language to be highlighted and requires a closing tag.

Options:

Expand Down
4 changes: 2 additions & 2 deletions content/en/content-management/taxonomies.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ wikipedia: "https://en.wikipedia.org/wiki/Bruce_Willis"
[content type]: /content-management/types/
[documentation on archetypes]: /content-management/archetypes/
[front matter]: /content-management/front-matter/
[taxonomy list templates]: /templates/taxonomy-templates/#taxonomy-list-templates
[taxonomy list templates]: /templates/taxonomy-templates/#taxonomy-templates
[taxonomy templates]: /templates/taxonomy-templates/
[terms within the taxonomy]: /templates/taxonomy-templates/#taxonomy-terms-templates
[terms within the taxonomy]: /templates/taxonomy-templates/#term-templates
[site configuration]: /getting-started/configuration/
2 changes: 1 addition & 1 deletion content/en/functions/collections/KeyVals.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ action:
aliases: [/functions/keyvals]
---

The primary application for this function is the definition of the `namedSlices` parameter in the options map passed to the [`Related`] method on the `Pages` object.
The primary application for this function is the definition of the `namedSlices` value in the options map passed to the [`Related`] method on the `Pages` object.

[`Related`]: /methods/pages/related/

Expand Down
2 changes: 1 addition & 1 deletion content/en/functions/fmt/Errorf.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ aliases: [/functions/errorf]
The `errorf` function evaluates the format string, then prints the result to the ERROR log and fails the build.

```go-html-template
{{ errorf "The %q shortcode requires a src parameter. See %s" .Name .Position }}
{{ errorf "The %q shortcode requires a src argument. See %s" .Name .Position }}
```

Use the [`erroridf`] function to allow optional suppression of specific errors.
Expand Down
6 changes: 3 additions & 3 deletions content/en/functions/images/UnsharpMask.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ action:
toc: true
---

The sigma parameter is used in a gaussian function and affects the radius of effect. Sigma must be positive. The sharpen radius is approximately 3 times the sigma value.
The sigma argument is used in a gaussian function and affects the radius of effect. Sigma must be positive. The sharpen radius is approximately 3 times the sigma value.

The amount parameter controls how much darker and how much lighter the edge borders become. Typically between 0.5 and 1.5.
The amount argument controls how much darker and how much lighter the edge borders become. Typically between 0.5 and 1.5.

The threshold parameter controls the minimum brightness change that will be sharpened. Typically between 0 and 0.05.
The threshold argument controls the minimum brightness change that will be sharpened. Typically between 0 and 0.05.

## Usage

Expand Down
20 changes: 10 additions & 10 deletions content/en/methods/shortcode/Get.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Get
description: Returns the value of the given parameter.
description: Returns the value of the given argument.
categories: []
keywords: []
action:
Expand All @@ -12,40 +12,40 @@ action:
toc: true
---

Specify the parameter by position or by name. When calling a shortcode within Markdown, use either positional or named parameters, but not both.
Specify the argument by position or by name. When calling a shortcode within Markdown, use either positional or named argument, but not both.

{{% note %}}
Some shortcodes support positional parameters, some support named parameters, and others support both. Refer to the shortcode's documentation for usage details.
Some shortcodes support positional arguments, some support named arguments, and others support both. Refer to the shortcode's documentation for usage details.
{{% /note %}}

## Positional parameters
## Positional arguments

This shortcode call uses positional parameters:
This shortcode call uses positional arguments:

{{< code file=content/about.md lang=md >}}
{{</* myshortcode "Hello" "world" */>}}
{{< /code >}}

To retrieve parameters by position:
To retrieve arguments by position:

{{< code file=layouts/shortcodes/myshortcode.html >}}
{{ printf "%s %s." (.Get 0) (.Get 1) }} → Hello world.
{{< /code >}}

## Named parameters
## Named arguments

This shortcode call uses named parameters:
This shortcode call uses named arguments:

{{< code file=content/about.md lang=md >}}
{{</* myshortcode greeting="Hello" firstName="world" */>}}
{{< /code >}}

To retrieve parameters by name:
To retrieve arguments by name:

{{< code file=layouts/shortcodes/myshortcode.html >}}
{{ printf "%s %s." (.Get "greeting") (.Get "firstName") }} → Hello world.
{{< /code >}}

{{% note %}}
Parameter names are case-sensitive.
Argument names are case-sensitive.
{{% /note %}}
4 changes: 2 additions & 2 deletions content/en/methods/shortcode/IsNamedParams.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: IsNamedParams
description: Reports whether the shortcode call uses named parameters.
description: Reports whether the shortcode call uses named arguments.
categories: []
keywords: []
action:
Expand All @@ -10,7 +10,7 @@ action:
signatures: [SHORTCODE.IsNamedParams]
---

To support both positional and named parameters when calling a shortcode, use the `IsNamedParams` method to determine how the shortcode was called.
To support both positional and named arguments when calling a shortcode, use the `IsNamedParams` method to determine how the shortcode was called.

With this shortcode template:

Expand Down
8 changes: 4 additions & 4 deletions content/en/methods/shortcode/Name.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ action:
signatures: [SHORTCODE.Name]
---

The `Name` method is useful for error reporting. For example, if your shortcode requires a "greeting" parameter:
The `Name` method is useful for error reporting. For example, if your shortcode requires a "greeting" argument:

{{< code file=layouts/shortcodes/myshortcode.html >}}
{{ $greeting := "" }}
{{ with .Get "greeting" }}
{{ $greeting = . }}
{{ else }}
{{ errorf "The %q shortcode requires a 'greeting' parameter. See %s" .Name .Position }}
{{ errorf "The %q shortcode requires a 'greeting' argument. See %s" .Name .Position }}
{{ end }}
{{< /code >}}

In the absence of a "greeting" parameter, Hugo will throw an error message and fail the build:
In the absence of a "greeting" argument, Hugo will throw an error message and fail the build:

```text
ERROR The "myshortcode" shortcode requires a 'greeting' parameter. See "/home/user/project/content/about.md:11:1"
ERROR The "myshortcode" shortcode requires a 'greeting' argument. See "/home/user/project/content/about.md:11:1"
```
2 changes: 1 addition & 1 deletion content/en/methods/shortcode/Ordinal.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This shortcode performs error checking, then renders an HTML `img` element with
{{ errorf "The %q shortcode was unable to find %s. See %s" $.Name $src $.Position }}
{{ end }}
{{ else }}
{{ errorf "The %q shortcode requires a 'src' parameter. See %s" .Name .Position }}
{{ errorf "The %q shortcode requires a 'src' argument. See %s" .Name .Position }}
{{ end }}
{{< /code >}}

Expand Down
6 changes: 3 additions & 3 deletions content/en/methods/shortcode/Params.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Params
description: Returns a collection of the shortcode parameters.
description: Returns a collection of the shortcode arguments.
categories: []
keywords: []
action:
Expand All @@ -10,7 +10,7 @@ action:
signatures: [SHORTCODE.Params]
---

When you call a shortcode using positional parameters, the `Params` method returns a slice.
When you call a shortcode using positional arguments, the `Params` method returns a slice.

{{< code file=content/about.md lang=md >}}
{{</* myshortcode "Hello" "world" */>}}
Expand All @@ -21,7 +21,7 @@ When you call a shortcode using positional parameters, the `Params` method retur
{{ index .Params 1 }} → world
{{< /code >}}

When you call a shortcode using named parameters, the `Params` method returns a map.
When you call a shortcode using named arguments, the `Params` method returns a map.

{{< code file=content/about.md lang=md >}}
{{</* myshortcode greeting="Hello" name="world" */>}}
Expand Down
6 changes: 3 additions & 3 deletions content/en/methods/shortcode/Parent.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ action:
signatures: [SHORTCODE.Parent]
---

This is useful for inheritance of common shortcode parameters from the root.
This is useful for inheritance of common shortcode arguments from the root.

In this contrived example, the "greeting" shortcode is the parent, and the "now" shortcode is child.

Expand Down Expand Up @@ -45,6 +45,6 @@ Welcome. Today is {{</* now */>}}.

The "now" shortcode formats the current time using:

1. The `dateFormat` parameter passed to the "now" shortcode, if present
2. The `dateFormat` parameter passed to the "greeting" shortcode, if present
1. The `dateFormat` argument passed to the "now" shortcode, if present
2. The `dateFormat` argument passed to the "greeting" shortcode, if present
3. The default layout string defined at the top of the shortcode
8 changes: 4 additions & 4 deletions content/en/methods/shortcode/Position.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ action:
signatures: [SHORTCODE.Position]
---

The `Position` method is useful for error reporting. For example, if your shortcode requires a "greeting" parameter:
The `Position` method is useful for error reporting. For example, if your shortcode requires a "greeting" argument:

{{< code file=layouts/shortcodes/myshortcode.html >}}
{{ $greeting := "" }}
{{ with .Get "greeting" }}
{{ $greeting = . }}
{{ else }}
{{ errorf "The %q shortcode requires a 'greeting' parameter. See %s" .Name .Position }}
{{ errorf "The %q shortcode requires a 'greeting' argument. See %s" .Name .Position }}
{{ end }}
{{< /code >}}

In the absence of a "greeting" parameter, Hugo will throw an error message and fail the build:
In the absence of a "greeting" argument, Hugo will throw an error message and fail the build:

```text
ERROR The "myshortcode" shortcode requires a 'greeting' parameter. See "/home/user/project/content/about.md:11:1"
ERROR The "myshortcode" shortcode requires a 'greeting' argument. See "/home/user/project/content/about.md:11:1"
```

{{% note %}}
Expand Down
2 changes: 1 addition & 1 deletion content/en/templates/embedded.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ To include the embedded template:

### Configure X (Twitter) Cards

Hugo's X (Twitter) Card template is configured using a mix of configuration variables and [front-matter](/content-management/front-matter/) on individual pages.
Hugo's X (Twitter) Card template is configured using a mix of configuration settings and [front-matter](/content-management/front-matter/) values on individual pages.

{{< code-toggle file=hugo >}}
[params]
Expand Down
11 changes: 1 addition & 10 deletions content/en/templates/homepage.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ toc: true
aliases: [/layout/homepage/,/templates/homepage-template/]
---

Homepage is a `Page` and therefore has all the [page variables][pagevars] and [site variables][sitevars] available for use.

{{% note %}}
The homepage template is the *only* required template for building a site and therefore useful when bootstrapping a new site and template. It is also the only required template if you are developing a single-page website.
{{% /note %}}


{{< youtube ut1xtRZ1QOA >}}

Expand All @@ -32,8 +29,6 @@ See the homepage template below or [Content Organization][contentorg] for more i

## Example homepage template

The following is an example of a homepage template that uses [partial][partials], [base] templates, and a content file at `content/_index.md` to populate the `{{ .Title }}` and `{{ .Content }}` [page variables][pagevars].

{{< code file=layouts/index.html >}}
{{ define "main" }}
<main aria-role="main">
Expand All @@ -56,10 +51,6 @@ The following is an example of a homepage template that uses [partial][partials]
{{ end }}
{{< /code >}}

[base]: /templates/base/
[contentorg]: /content-management/organization/
[lists]: /templates/lists/
[lookup]: /templates/lookup-order/
[pagevars]: /methods/page/
[partials]: /templates/partials/
[sitevars]: /methods/site/
24 changes: 3 additions & 21 deletions content/en/templates/lists/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,9 @@ The idea of a list page comes from the [hierarchical mental model of the web][me

[![Image demonstrating a hierarchical website sitemap.](site-hierarchy.svg)](site-hierarchy.svg)

## List defaults

### Default templates

Since section lists and taxonomy lists (N.B., *not* [taxonomy terms lists][taxterms]) are both *lists* with regards to their templates, both have the same terminating default of `_default/list.html` or `themes/<THEME>/layouts/_default/list.html` in their lookup order. In addition, both [section lists][sectiontemps] and [taxonomy lists][taxlists] have their own default list templates in `_default`.

See [Template Lookup Order](/templates/lookup-order/) for the complete reference.

## Add content and front matter to list pages

Since v0.18, [everything in Hugo is a `Page`][bepsays]. This means list pages and the homepage can have associated content files (i.e. `_index.md`) that contain page metadata (i.e., front matter) and content.

This new model allows you to include list-specific front matter via `.Params` and also means that list templates (e.g., `layouts/_default/list.html`) have access to all [page variables][pagevars].

{{% note %}}
It is important to note that all `_index.md` content files will render according to a *list* template and not according to a [single page template](/templates/single-page-templates/).
{{% /note %}}

### Example project directory
Add content and front matter to list pages by creating an _index.md file for `home`, `section`, `taxonomy`, and `term` pages.

The following is an example of a typical Hugo project directory's content:

Expand Down Expand Up @@ -241,15 +225,13 @@ See the documentation on [`where`] and
[getpage]: /methods/page/getpage/
[homepage]: /templates/homepage/
[mentalmodel]: https://webstyleguide.com/wsg3/3-information-architecture/3-site-structure.html
[pagevars]: /methods/page/
[partials]: /templates/partials/
[RSS 2.0]: https://cyber.harvard.edu/rss/rss.html
[rss]: /templates/rss/
[sections]: /content-management/sections/
[sectiontemps]: /templates/section-templates/
[sitevars]: /methods/site/
[taxlists]: /templates/taxonomy-templates/#taxonomy-list-templates
[taxterms]: /templates/taxonomy-templates/#taxonomy-terms-templates
[taxlists]: /templates/taxonomy-templates/#taxonomy-templates
[taxterms]: /templates/taxonomy-templates/#term-templates
[taxvars]: /methods/taxonomy/
[views]: /templates/views/
[`where`]: /functions/collections/where/
Expand Down
Loading