Merge commit 'a024bc7d76fcc5e49e8210f9b0896db9ef21861a'

This commit is contained in:
Bjørn Erik Pedersen
2025-02-13 10:40:34 +01:00
817 changed files with 5301 additions and 14766 deletions

View File

@@ -1,7 +1,7 @@
---
title: Methods
linkTitle: In this section
description: A list of Hugo template methods including examples.
description: Use these methods within your templates.
categories: []
keywords: []
menu:

View File

@@ -16,7 +16,7 @@ action:
signatures: [PAGE.Ancestors]
---
{{% include "methods/page/_common/definition-of-section.md" %}}
{{% glossary-term section %}}
With this content structure:

View File

@@ -15,7 +15,7 @@ action:
signatures: [PAGE.ContentWithoutSummary]
---
{{< new-in 0.134.0 >}}
{{< new-in 0.134.0 />}}
Applicable when using manual or automatic [content summaries], the `ContentWithoutSummary` method on a `Page` object renders Markdown and shortcodes to HTML, excluding the content summary from the result.

View File

@@ -16,7 +16,7 @@ action:
signatures: [PAGE.CurrentSection]
---
{{% include "methods/page/_common/definition-of-section.md" %}}
{{% glossary-term section %}}
{{% note %}}
The current section of a [section page](g), [taxonomy page](g), [term page](g), or the home page, is itself.

View File

@@ -12,7 +12,7 @@ toc: true
By default, not all pages are backed by a file, including top level [section pages](g), [taxonomy pages](g), and [term pages](g). By definition, you cannot retrieve file information when the file does not exist.
To back one of the pages above with a file, create an `_index.md` file in the corresponding directory. For example:
To back one of the pages above with a file, create an&nbsp;`_index.md`&nbsp;file in the corresponding directory. For example:
```text
content/
@@ -84,7 +84,7 @@ The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend
###### IsContentAdapter
{{< new-in 0.126.0 >}}
{{< new-in 0.126.0 />}}
(`bool`) Reports whether the file is a [content adapter].

View File

@@ -16,7 +16,7 @@ action:
signatures: [PAGE.FirstSection]
---
{{% include "methods/page/_common/definition-of-section.md" %}}
{{% glossary-term section %}}
{{% note %}}
When called on the home page, the `FirstSection` method returns the `Page` object of the home page itself.

View File

@@ -19,7 +19,7 @@ toc: true
The `InSection` method on a `Page` object reports whether the given page is in the given section. Note that the method returns `true` when comparing a page to a sibling.
{{% include "methods/page/_common/definition-of-section.md" %}}
{{% glossary-term section %}}
With this content structure:

View File

@@ -17,7 +17,7 @@ action:
toc: true
---
{{% include "methods/page/_common/definition-of-section.md" %}}
{{% glossary-term section %}}
With this content structure:

View File

@@ -16,7 +16,7 @@ action:
signatures: [PAGE1.IsDescendant PAGE2]
---
{{% include "methods/page/_common/definition-of-section.md" %}}
{{% glossary-term section %}}
With this content structure:

View File

@@ -70,7 +70,7 @@ When rendering lesson-2, the `Pages` method returns:
lessons/lesson-2/resources/task-list.md
lessons/lesson-2/resources/worksheet.md
In the last example, the collection includes pages in the resources subdirectory. That directory is not a [section](g)---it does not contain an `_index.md` file. Its contents are part of the lesson-2 section.
In the last example, the collection includes pages in the resources subdirectory. That directory is not a [section](g)---it does not contain an&nbsp;`_index.md`&nbsp;file. Its contents are part of the lesson-2 section.
{{% note %}}
When used with a `Site` object, the `Pages` method recursively returns all pages within the site. See&nbsp;[details].

View File

@@ -16,7 +16,7 @@ action:
signatures: [PAGE.Parent]
---
{{% include "methods/page/_common/definition-of-section.md" %}}
{{% glossary-term section %}}
{{% note %}}
The parent section of a regular page is the [current section].

View File

@@ -12,7 +12,7 @@ action:
toc: true
---
{{< new-in 0.123.0 >}}
{{< new-in 0.123.0 />}}
The `Path` method on a `Page` object returns the [logical path](g) of the given page, regardless of whether the page is backed by a file.

View File

@@ -67,7 +67,7 @@ When rendering lesson-2, the `RegularPages` method returns:
lessons/lesson-2/resources/task-list.md
lessons/lesson-2/resources/worksheet.md
In the last example, the collection includes pages in the resources subdirectory. That directory is not a [section](g)---it does not contain an _index.md file. Its contents are part of the lesson-2 section.
In the last example, the collection includes pages in the resources subdirectory. That directory is not a [section](g)---it does not contain an&nbsp;`_index.md`&nbsp;file. Its contents are part of the lesson-2 section.
{{% note %}}
When used with the `Site` object, the `RegularPages` method recursively returns all regular pages within the site. See&nbsp;[details].

View File

@@ -17,7 +17,7 @@ action:
toc: true
---
{{< new-in 0.117.0 >}}
{{< new-in 0.117.0 />}}
Use this method in shortcode templates to compose a page from multiple content files, while preserving a global context for footnotes and the table of contents.

View File

@@ -71,7 +71,7 @@ When working with global resources instead of page resources, use the [`resource
###### Mount
{{< new-in "0.140.0" >}}
{{< new-in 0.140.0 />}}
(`ResourceGetter`) Mounts the given resources from the two arguments base (`string`) to the given target path (`string`) and returns an object that implements [Get](#get). Note that leading slashes in target marks an absolute path. Relative target paths allows you to mount resources relative to another set, e.g. a [Page bundle](/content-management/page-bundles/):

View File

@@ -1,17 +1,13 @@
---
title: Scratch
description: Returns a "scratch pad" on the given page to store and manipulate data.
description: Returns a "scratch pad" to store and manipulate data, scoped to the current page.
categories: []
keywords: []
action:
related:
- methods/page/Store
- functions/collections/NewScratch
related: []
returnType: maps.Scratch
signatures: [PAGE.Scratch]
toc: true
aliases: [/extras/scratch/,/doc/scratch/,/functions/scratch]
expiryDate: 2025-11-18 # deprecated 2024-11-18
expiryDate: 2026-11-18 # deprecated 2024-11-18 (soft)
---
{{% deprecated-in 0.138.0 %}}
@@ -23,30 +19,3 @@ Beginning with v0.138.0 the `PAGE.Scratch` method is aliased to `PAGE.Store`.
[`PAGE.Store`]: /methods/page/store/
{{% /deprecated-in %}}
The `Scratch` method on a `Page` object creates a [scratch pad](g) to store and manipulate data. To create a scratch pad that is not reset on server rebuilds, use the [`Store`] method instead.
To create a locally scoped scratch pad that is not attached to a `Page` object, use the [`newScratch`] function.
[`Store`]: /methods/page/store/
[`newScratch`]: /functions/collections/newscratch/
{{% include "methods/page/_common/scratch-methods.md" %}}
## Determinate values
The `Scratch` method is often used to set scratch pad values within a shortcode, a partial template called by a shortcode, or by a Markdown render hook. In all three cases, the scratch pad values are indeterminate until Hugo renders the page content.
If you need to access a scratch pad value from a parent template, and the parent template has not yet rendered the page content, you can trigger content rendering by assigning the returned value to a [noop](g) variable:
```go-html-template
{{ $noop := .Content }}
{{ .Store.Get "mykey" }}
```
You can also trigger content rendering with the `ContentWithoutSummary`, `FuzzyWordCount`, `Len`, `Plain`, `PlainWords`, `ReadingTime`, `Summary`, `Truncated`, and `WordCount` methods. For example:
```go-html-template
{{ $noop := .WordCount }}
{{ .Store.Get "mykey" }}
```

View File

@@ -16,7 +16,7 @@ action:
signatures: [PAGE.Sections]
---
{{% include "methods/page/_common/definition-of-section.md" %}}
{{% glossary-term section %}}
With this content structure:

View File

@@ -15,13 +15,13 @@ Access to the `Sitemap` method on a `Page` object is restricted to [sitemap temp
## Methods
changefreq
: (`string`) How frequently a page is likely to change. Valid values are `always`, `hourly`, `daily`, `weekly`, `monthly`, `yearly`, and `never`. With the default value of `""` Hugo will omit this field from the sitemap. See [details](https://www.sitemaps.org/protocol.html#changefreqdef).
: (`string`) How frequently a page is likely to change. Valid values are `always`, `hourly`, `daily`, `weekly`, `monthly`, `yearly`, and `never`. With the default value of `""` Hugo will omit this field from the sitemap. See&nbsp;[details](https://www.sitemaps.org/protocol.html#changefreqdef).
```go-html-template
{{ .Sitemap.ChangeFreq }}
```
disable {{< new-in 0.125.0 >}}
disable {{< new-in 0.125.0 />}}
: (`bool`) Whether to disable page inclusion. Default is `false`. Set to `true` in front matter to exclude the page.
```go-html-template
@@ -29,7 +29,7 @@ disable {{< new-in 0.125.0 >}}
```
priority
: (`float`) The priority of a page relative to any other page on the site. Valid values range from 0.0 to 1.0. With the default value of `-1` Hugo will omit this field from the sitemap. See [details](https://www.sitemaps.org/protocol.html#priority).
: (`float`) The priority of a page relative to any other page on the site. Valid values range from 0.0 to 1.0. With the default value of `-1` Hugo will omit this field from the sitemap. See&nbsp;[details](https://www.sitemaps.org/protocol.html#priority).
```go-html-template
{{ .Sitemap.Priority }}

View File

@@ -1,108 +1,25 @@
---
title: Store
linktitle: PAGE.Store
description: Returns a persistent "scratch pad" on the given page to store and manipulate data.
description: Returns a "scratch pad" to store and manipulate data, scoped to the current page.
categories: []
keywords: []
action:
related:
- methods/page/scratch
- methods/site/store
- functions/hugo/store
- functions/collections/NewScratch
- methods/site/Store
- methods/shortcode/Store
- functions/hugo/Store
- functions/collections/NewScratch
returnType: maps.Scratch
signatures: [PAGE.Store]
toc: true
aliases: [/functions/store]
aliases: [/functions/store/,/extras/scratch/,/doc/scratch/,/functions/scratch]
---
The `Store` method on a `Page` object creates a persistent [scratch pad](g) to store and manipulate data. To create a locally scoped scratch pad that is not attached to a `Page` object, use the [`newScratch`] function.
Use the `Store` method on a `Page` object to create a [scratch pad](g) to store and manipulate data, scoped to the current page. To create a scratch pad with a different [scope](g), refer to the [scope](#scope) section below.
[`Scratch`]: /methods/page/scratch/
[`newScratch`]: /functions/collections/newscratch/
{{% include "_common/store-methods.md" %}}
## Methods
###### Set
Sets the value of a given key.
```go-html-template
{{ .Store.Set "greeting" "Hello" }}
```
###### Get
Gets the value of a given key.
```go-html-template
{{ .Store.Set "greeting" "Hello" }}
{{ .Store.Get "greeting" }} → Hello
```
###### Add
Adds 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.
```go-html-template
{{ .Store.Set "greeting" "Hello" }}
{{ .Store.Add "greeting" "Welcome" }}
{{ .Store.Get "greeting" }} → HelloWelcome
```
```go-html-template
{{ .Store.Set "total" 3 }}
{{ .Store.Add "total" 7 }}
{{ .Store.Get "total" }} → 10
```
```go-html-template
{{ .Store.Set "greetings" (slice "Hello") }}
{{ .Store.Add "greetings" (slice "Welcome" "Cheers") }}
{{ .Store.Get "greetings" }} → [Hello Welcome Cheers]
```
###### SetInMap
Takes a `key`, `mapKey` and `value` and adds a map of `mapKey` and `value` to the given `key`.
```go-html-template
{{ .Store.SetInMap "greetings" "english" "Hello" }}
{{ .Store.SetInMap "greetings" "french" "Bonjour" }}
{{ .Store.Get "greetings" }} → map[english:Hello french:Bonjour]
```
###### DeleteInMap
Takes a `key` and `mapKey` and removes the map of `mapKey` from the given `key`.
```go-html-template
{{ .Store.SetInMap "greetings" "english" "Hello" }}
{{ .Store.SetInMap "greetings" "french" "Bonjour" }}
{{ .Store.DeleteInMap "greetings" "english" }}
{{ .Store.Get "greetings" }} → map[french:Bonjour]
```
###### GetSortedMapValues
Returns an array of values from `key` sorted by `mapKey`.
```go-html-template
{{ .Store.SetInMap "greetings" "english" "Hello" }}
{{ .Store.SetInMap "greetings" "french" "Bonjour" }}
{{ .Store.GetSortedMapValues "greetings" }} → [Hello Bonjour]
```
###### Delete
Removes the given key.
```go-html-template
{{ .Store.Set "greeting" "Hello" }}
{{ .Store.Delete "greeting" }}
```
{{% include "_common/scratch-pad-scope.md" %}}
## Determinate values

View File

@@ -33,7 +33,7 @@ You can change the capitalization style in your site configuration to one of `ap
titleCaseStyle = "firstupper"
{{< /code-toggle >}}
See [details].
See&nbsp;[details].
[`capitalizeListTitles`]: /getting-started/configuration/#capitalizelisttitles
[`pluralizeListTitles`]: /getting-started/configuration/#pluralizelisttitles

View File

@@ -7,7 +7,6 @@ action:
related:
- methods/page/Kind
- methods/page/Layout
- methods/page/Type
returnType: string
signatures: [PAGE.Type]
---

View File

@@ -1,5 +0,0 @@
---
_comment: Do not remove front matter.
---
A _section_ is a top-level content directory, or any content directory with an&nbsp;`_index.md`&nbsp;file.

View File

@@ -1,86 +0,0 @@
---
_comment: Do not remove front matter.
---
## Methods
###### Set
Sets the value of a given key.
```go-html-template
{{ .Scratch.Set "greeting" "Hello" }}
```
###### Get
Gets the value of a given key.
```go-html-template
{{ .Scratch.Set "greeting" "Hello" }}
{{ .Scratch.Get "greeting" }} → Hello
```
###### Add
Adds 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.
```go-html-template
{{ .Scratch.Set "greeting" "Hello" }}
{{ .Scratch.Add "greeting" "Welcome" }}
{{ .Scratch.Get "greeting" }} → HelloWelcome
```
```go-html-template
{{ .Scratch.Set "total" 3 }}
{{ .Scratch.Add "total" 7 }}
{{ .Scratch.Get "total" }} → 10
```
```go-html-template
{{ .Scratch.Set "greetings" (slice "Hello") }}
{{ .Scratch.Add "greetings" (slice "Welcome" "Cheers") }}
{{ .Scratch.Get "greetings" }} → [Hello Welcome Cheers]
```
###### SetInMap
Takes a `key`, `mapKey` and `value` and adds a map of `mapKey` and `value` to the given `key`.
```go-html-template
{{ .Scratch.SetInMap "greetings" "english" "Hello" }}
{{ .Scratch.SetInMap "greetings" "french" "Bonjour" }}
{{ .Scratch.Get "greetings" }} → map[english:Hello french:Bonjour]
```
###### DeleteInMap
Takes a `key` and `mapKey` and removes the map of `mapKey` from the given `key`.
```go-html-template
{{ .Scratch.SetInMap "greetings" "english" "Hello" }}
{{ .Scratch.SetInMap "greetings" "french" "Bonjour" }}
{{ .Scratch.DeleteInMap "greetings" "english" }}
{{ .Scratch.Get "greetings" }} → map[french:Bonjour]
```
###### GetSortedMapValues
Returns an array of values from `key` sorted by `mapKey`.
```go-html-template
{{ .Scratch.SetInMap "greetings" "english" "Hello" }}
{{ .Scratch.SetInMap "greetings" "french" "Bonjour" }}
{{ .Scratch.GetSortedMapValues "greetings" }} → [Hello Bonjour]
```
###### Delete
Removes the given key.
```go-html-template
{{ .Scratch.Set "greeting" "Hello" }}
{{ .Scratch.Delete "greeting" }}
```

View File

@@ -4,11 +4,10 @@ description: Returns the number of pages per pager.
categories: []
keywords: []
action:
related:
- methods/page/Paginate
related: []
returnType: int
signatures: [PAGER.PageSize]
expiryDate: 2025-06-09 # deprecated 2024-06-09
expiryDate: 2026-06-09 # deprecated 2024-06-09 in v0.128.0
---
{{% deprecated-in 0.128.0 %}}
@@ -16,21 +15,3 @@ Use [`PAGER.PagerSize`] instead.
[`PAGER.PagerSize`]: /methods/pager/pagersize/
{{% /deprecated-in %}}
The number of pages per pager is determined by the optional second argument passed to the [`Paginate`] method, falling back to the `pagerSize` as defined in your [site configuration].
[`Paginate`]: /methods/page/paginate/
[site configuration]: /templates/pagination/#configuration
```go-html-template
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ with $paginator }}
{{ .PageSize }}
{{ end }}
```

View File

@@ -10,7 +10,7 @@ action:
signatures: [PAGER.PagerSize]
---
{{< new-in 0.128.0 >}}
{{< new-in 0.128.0 />}}
The number of pages per pager is determined by the optional second argument passed to the [`Paginate`] method, falling back to the `pagerSize` as defined in your [site configuration].

View File

@@ -20,11 +20,11 @@ The `Resources.Colors` method returns a slice of the most dominant colors in an
Each color is an object with the following methods:
ColorHex
{{< new-in 0.125.0 >}}
{{< new-in 0.125.0 />}}
: (`string`) Returns the [hexadecimal color] value, prefixed with a hash sign.
Luminance
{{< new-in 0.125.0 >}}
{{< new-in 0.125.0 />}}
: (`float64`) Returns the [relative luminance] of the color in the sRGB colorspace in the range [0, 1]. A value of `0` represents the darkest black, while a value of `1` represents the lightest white.
{{% note %}}

View File

@@ -17,6 +17,7 @@ The `Data` method on a resource returned by the [`resources.GetRemote`] function
```go-html-template
{{ $url := "https://example.org/images/a.jpg" }}
{{ $opts := dict "responseHeaders" (slice "Server") }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
@@ -24,6 +25,7 @@ The `Data` method on a resource returned by the [`resources.GetRemote`] function
{{ with .Data }}
{{ .ContentLength }} → 42764
{{ .ContentType }} → image/jpeg
{{ .Headers }} → map[Server:[Netlify]]
{{ .Status }} → 200 OK
{{ .StatusCode }} → 200
{{ .TransferEncoding }} → []
@@ -34,19 +36,30 @@ The `Data` method on a resource returned by the [`resources.GetRemote`] function
{{ end }}
```
ContentLength
: (`int`) The content length in bytes.
###### ContentLength
ContentType
: (`string`) The content type.
(`int`) The content length in bytes.
Status
: (`string`) The HTTP status text.
###### ContentType
StatusCode
: (`int`) The HTTP status code.
(`string`) The content type.
TransferEncoding
: (`string`) The transfer encoding.
###### Headers
(`map[string][]string`) A map of response headers matching those requested in the [`responseHeaders`] option passed to the `resources.GetRemote` function. The header name matching is case-insensitive. In most cases there will be one value per header key.
[`responseHeaders`]: /functions/resources/getremote/#responseheaders
###### Status
(`string`) The HTTP status text.
###### StatusCode
(`int`) The HTTP status code.
###### TransferEncoding
(`string`) The transfer encoding.
[`resources.GetRemote`]: /functions/resources/getremote/

View File

@@ -9,7 +9,7 @@ action:
- methods/resource/Data
returnType: resource.resourceError
signatures: [RESOURCE.Err]
expiryDate: 2026-01-16 # deprecated 2025-01-16
expiryDate: 2027-01-16 # deprecated 2025-01-16 in v0.141.0
---
{{% deprecated-in 0.141.0 %}}

View File

@@ -1,14 +1,13 @@
---
title: Scratch
description: Returns a "scratch pad" scoped to the shortcode to store and manipulate data.
description: Returns a "scratch pad" to store and manipulate data, scoped to the current shortcode.
categories: []
keywords: []
action:
related:
- functions/collections/NewScratch
related: []
returnType: maps.Scratch
signatures: [SHORTCODE.Scratch]
expiryDate: 2025-11-18 # deprecated 2024-11-18
expiryDate: 2026-11-18 # deprecated 2024-11-18 (soft)
---
{{% deprecated-in 0.139.0 %}}
@@ -20,14 +19,3 @@ Beginning with v0.139.0 the `SHORTCODE.Scratch` method is aliased to `SHORTCODE.
[`SHORTCODE.Store`]: /methods/shortcode/store/
{{% /deprecated-in %}}
The `Scratch` method within a shortcode creates a [scratch pad](g) to store and manipulate data. The scratch pad is scoped to the shortcode.
{{% note %}}
With the introduction of the [`newScratch`] function, and the ability to [assign values to template variables] after initialization, the `Scratch` method within a shortcode is obsolete.
[assign values to template variables]: https://go.dev/doc/go1.11#text/template
[`newScratch`]: /functions/collections/newscratch/
{{% /note %}}
{{% include "methods/page/_common/scratch-methods.md" %}}

View File

@@ -1,21 +1,22 @@
---
title: Store
description: Returns a "Store pad" scoped to the shortcode to store and manipulate data.
description: Returns a "scratch pad" to store and manipulate data, scoped to the current shortcode.
categories: []
keywords: []
action:
related:
- functions/collections/NewScratch
- methods/page/Store
- methods/site/Store
- functions/hugo/Store
returnType: maps.Store
- functions/collections/NewScratch
returnType: maps.Scratch
signatures: [SHORTCODE.Store]
toc: true
---
{{< new-in 0.139.0 >}}
{{< new-in 0.139.0 />}}
The `Store` method within a shortcode creates a [scratch pad](g) to store and manipulate data. The scratch pad is scoped to the shortcode.
Use the `Store` method to create a [scratch pad](g) to store and manipulate data, scoped to the current shortcode. To create a scratch pad with a different [scope](g), refer to the [scope](#scope) section below.
{{% note %}}
With the introduction of the [`newScratch`] function, and the ability to [assign values to template variables] after initialization, the `Store` method within a shortcode is mostly obsolete.
@@ -24,4 +25,6 @@ With the introduction of the [`newScratch`] function, and the ability to [assign
[`newScratch`]: /functions/collections/newScratch/
{{% /note %}}
{{% include "methods/page/_common/scratch-methods.md" %}}
{{% include "_common/store-methods.md" %}}
{{% include "_common/scratch-pad-scope.md" %}}

View File

@@ -7,6 +7,7 @@ keywords: []
menu:
docs:
parent: methods
aliases: [/variables/shortcodes]
---
Use these methods in your shortcode templates.

View File

@@ -7,7 +7,7 @@ action:
related: []
returnType: string
signatures: [SITE.DisqusShortname]
expiryDate: 2024-10-30 # deprecated 2023-10-30
expiryDate: 2025-10-30 # deprecated 2023-10-30 in v0.120.0
---
{{% deprecated-in 0.120.0 %}}

View File

@@ -7,7 +7,7 @@ action:
related: []
returnType: string
signatures: [SITE.GoogleAnalytics]
expiryDate: 2024-10-30 # deprecated 2023-10-30
expiryDate: 2025-10-30 # deprecated 2023-10-30 in v0.120.0
---
{{% deprecated-in 0.120.0 %}}

View File

@@ -7,7 +7,7 @@ action:
related: []
returnType: bool
signatures: [SITE.IsDevelopment]
expiryDate: 2024-10-30 # deprecated 2023-10-30
expiryDate: 2025-10-30 # deprecated 2023-10-30 in v0.120.0
---
{{% deprecated-in 0.120.0 %}}
@@ -15,7 +15,3 @@ Use [`hugo.IsDevelopment`] instead.
[`hugo.IsDevelopment`]: /functions/hugo/isdevelopment/
{{% /deprecated-in %}}
```go-html-template
{{ .Site.IsDevelopment }} → true/false
```

View File

@@ -7,7 +7,7 @@ action:
related: []
returnType: bool
signatures: [SITE.IsMultiLingual]
expiryDate: 2025-03-16 # deprecated 2024-03-16
expiryDate: 2026-03-16 # deprecated 2024-03-16 in 0.124.0
---
{{% deprecated-in 0.124.0 %}}
@@ -15,27 +15,3 @@ Use [`hugo.IsMultilingual`] instead.
[`hugo.IsMultilingual`]: /functions/hugo/ismultilingual/
{{% /deprecated-in %}}
Site configuration:
{{< code-toggle file=hugo >}}
defaultContentLanguage = 'de'
defaultContentLanguageInSubdir = true
[languages]
[languages.de]
languageCode = 'de-DE'
languageName = 'Deutsch'
title = 'Projekt Dokumentation'
weight = 1
[languages.en]
languageCode = 'en-US'
languageName = 'English'
title = 'Project Documentation'
weight = 2
{{< /code-toggle >}}
Template:
```go-html-template
{{ .Site.IsMultiLingual }} → true
```

View File

@@ -7,7 +7,7 @@ action:
related: []
returnType: bool
signatures: [SITE.IsServer]
expiryDate: 2024-10-30 # deprecated 2023-10-30
expiryDate: 2025-10-30 # deprecated 2023-10-30 in v0.120.0
---
{{% deprecated-in 0.120.0 %}}
@@ -15,7 +15,3 @@ Use [`hugo.IsServer`] instead.
[`hugo.IsServer`]: /functions/hugo/isserver/
{{% /deprecated-in %}}
```go-html-template
{{ .Site.IsServer }} → true/false
```

View File

@@ -7,7 +7,7 @@ action:
related: []
returnType: time.Time
signatures: [SITE.LastChange]
expiryDate: 2025-02-19 # deprecated 2024-02-19
expiryDate: 2026-02-19 # deprecated 2024-02-19 in v0.123.0
---
{{% deprecated-in 0.123.0 %}}
@@ -15,14 +15,3 @@ Use [`.Site.Lastmod`] instead.
[`.Site.Lastmod`]: /methods/site/lastmod/
{{% /deprecated-in %}}
The `LastChange` method on a `Site` object returns a [`time.Time`] value. Use this with time [functions] and [methods]. For example:
```go-html-template
{{ .Site.LastChange | time.Format ":date_long" }} → January 31, 2024
```
[`time.Time`]: https://pkg.go.dev/time#Time
[functions]: /functions/time/
[methods]: /methods/time/

View File

@@ -9,7 +9,7 @@ action:
signatures: [SITE.Lastmod]
---
{{< new-in 0.123.0 >}}
{{< new-in 0.123.0 />}}
The `Lastmod` method on a `Site` object returns a [`time.Time`] value. Use this with time [functions] and [methods]. For example:

View File

@@ -1,7 +1,6 @@
---
title: Store
linktitle: site.Store
description: Returns a persistent "scratch pad" on the given site to store and manipulate data.
description: Returns a "scratch pad" to store and manipulate data, scoped to the current site.
categories: []
keywords: []
action:
@@ -14,12 +13,9 @@ action:
toc: true
---
{{< new-in 0.139.0 >}}
{{< new-in 0.139.0 />}}
The `Store` method on a `Site` object creates a persistent [scratch pad](g) to store and manipulate data. To create a locally scoped scratch pad that is not attached to a `Site` object, use the [`newScratch`] function.
[`Scratch`]: /methods/site/scratch/
[`newScratch`]: /functions/collections/newscratch/
Use the `Store` method on a `Site` object to create a [scratch pad](g) to store and manipulate data, scoped to the current site. To create a scratch pad with a different [scope](g), refer to the [scope](#scope) section below.
## Methods
@@ -104,6 +100,8 @@ Removes the given key.
{{ site.Store.Delete "greeting" }}
```
{{% include "_common/scratch-pad-scope.md" %}}
## Determinate values
The `Store` method is often used to set scratch pad values within a shortcode, a partial template called by a shortcode, or by a Markdown render hook. In all three cases, the scratch pad values are indeterminate until Hugo renders the page content.

View File

@@ -9,7 +9,7 @@ action:
signatures: [TAXONOMY.Page]
---
{{< new-in 0.125.0 >}}
{{< new-in 0.125.0 />}}
This `TAXONOMY` method returns nil if the taxonomy has no terms, so you must code defensively: