mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-23 21:53:09 +02:00
Merge commit 'a024bc7d76fcc5e49e8210f9b0896db9ef21861a'
This commit is contained in:
@@ -16,7 +16,7 @@ action:
|
||||
signatures: [PAGE.Ancestors]
|
||||
---
|
||||
|
||||
{{% include "methods/page/_common/definition-of-section.md" %}}
|
||||
{{% glossary-term section %}}
|
||||
|
||||
With this content structure:
|
||||
|
||||
|
@@ -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.
|
||||
|
||||
|
@@ -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.
|
||||
|
@@ -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 `_index.md` 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].
|
||||
|
||||
|
@@ -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.
|
||||
|
@@ -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:
|
||||
|
||||
|
@@ -17,7 +17,7 @@ action:
|
||||
toc: true
|
||||
---
|
||||
|
||||
{{% include "methods/page/_common/definition-of-section.md" %}}
|
||||
{{% glossary-term section %}}
|
||||
|
||||
With this content structure:
|
||||
|
||||
|
@@ -16,7 +16,7 @@ action:
|
||||
signatures: [PAGE1.IsDescendant PAGE2]
|
||||
---
|
||||
|
||||
{{% include "methods/page/_common/definition-of-section.md" %}}
|
||||
{{% glossary-term section %}}
|
||||
|
||||
With this content structure:
|
||||
|
||||
|
@@ -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 `_index.md` 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 [details].
|
||||
|
@@ -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].
|
||||
|
@@ -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.
|
||||
|
||||
|
@@ -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 `_index.md` 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 [details].
|
||||
|
@@ -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.
|
||||
|
||||
|
@@ -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/):
|
||||
|
||||
|
@@ -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" }}
|
||||
```
|
||||
|
@@ -16,7 +16,7 @@ action:
|
||||
signatures: [PAGE.Sections]
|
||||
---
|
||||
|
||||
{{% include "methods/page/_common/definition-of-section.md" %}}
|
||||
{{% glossary-term section %}}
|
||||
|
||||
With this content structure:
|
||||
|
||||
|
@@ -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 [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 [details](https://www.sitemaps.org/protocol.html#priority).
|
||||
|
||||
```go-html-template
|
||||
{{ .Sitemap.Priority }}
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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 [details].
|
||||
|
||||
[`capitalizeListTitles`]: /getting-started/configuration/#capitalizelisttitles
|
||||
[`pluralizeListTitles`]: /getting-started/configuration/#pluralizelisttitles
|
||||
|
@@ -7,7 +7,6 @@ action:
|
||||
related:
|
||||
- methods/page/Kind
|
||||
- methods/page/Layout
|
||||
- methods/page/Type
|
||||
returnType: string
|
||||
signatures: [PAGE.Type]
|
||||
---
|
||||
|
@@ -1,5 +0,0 @@
|
||||
---
|
||||
_comment: Do not remove front matter.
|
||||
---
|
||||
|
||||
A _section_ is a top-level content directory, or any content directory with an `_index.md` 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" }}
|
||||
```
|
Reference in New Issue
Block a user