mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-19 04:16:02 +00:00
content: Consolidate configuration documentation
This commit is contained in:
1 parent
727ef6f665
commit
b6cae5cbc6
911 files changed
+10902
-11171
No files matched your search
@@ -1,17 +1,8 @@
|
||||
---
|
||||
title: Methods
|
||||
|
||||
description: Use these methods within your templates.
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
identifier: methods-in-this-section
|
||||
parent: methods
|
||||
weight: 10
|
||||
weight: 10
|
||||
showSectionMenu: true
|
||||
aliases: ['/variables/']
|
||||
---
|
||||
|
||||
Use these methods within your templates.
|
||||
@@ -3,12 +3,13 @@ title: Abs
|
||||
description: Returns the absolute value of the given time.Duration value.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: time.Duration
|
||||
signatures: [DURATION.Abs]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: time.Duration
|
||||
signatures: [DURATION.Abs]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -3,12 +3,13 @@ title: Hours
|
||||
description: Returns the time.Duration value as a floating point number of hours.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: float64
|
||||
signatures: [DURATION.Hours]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: float64
|
||||
signatures: [DURATION.Hours]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -3,12 +3,13 @@ title: Microseconds
|
||||
description: Returns the time.Duration value as an integer microsecond count.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: int64
|
||||
signatures: [DURATION.Microseconds]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: int64
|
||||
signatures: [DURATION.Microseconds]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -3,12 +3,13 @@ title: Milliseconds
|
||||
description: Returns the time.Duration value as an integer millisecond count.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: int64
|
||||
signatures: [DURATION.Milliseconds]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: int64
|
||||
signatures: [DURATION.Milliseconds]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -3,12 +3,13 @@ title: Minutes
|
||||
description: Returns the time.Duration value as a floating point number of minutes.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: float64
|
||||
signatures: [DURATION.Minutes]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: float64
|
||||
signatures: [DURATION.Minutes]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -3,12 +3,13 @@ title: Nanoseconds
|
||||
description: Returns the time.Duration value as an integer nanosecond count.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: int64
|
||||
signatures: [DURATION.Nanoseconds]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: int64
|
||||
signatures: [DURATION.Nanoseconds]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -3,12 +3,13 @@ title: Round
|
||||
description: Returns the result of rounding DURATION1 to the nearest multiple of DURATION2.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType:
|
||||
signatures: [DURATION1.Round DURATION2]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType:
|
||||
signatures: [DURATION1.Round DURATION2]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -3,12 +3,13 @@ title: Seconds
|
||||
description: Returns the time.Duration value as a floating point number of seconds.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: float64
|
||||
signatures: [DURATION.Seconds]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: float64
|
||||
signatures: [DURATION.Seconds]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -3,12 +3,13 @@ title: Truncate
|
||||
description: Returns the result of rounding DURATION1 toward zero to a multiple of DURATION2.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: time.Duration
|
||||
signatures: [DURATION1.Truncate DURATION2]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- functions/time/Duration
|
||||
- functions/time/ParseDuration
|
||||
returnType: time.Duration
|
||||
signatures: [DURATION1.Truncate DURATION2]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -4,9 +4,4 @@ linkTitle: Duration
|
||||
description: Use these methods with time.Duration values.
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: methods
|
||||
---
|
||||
|
||||
Use these methods with time.Duration values.
|
||||
@@ -3,11 +3,12 @@ title: Children
|
||||
description: Returns a collection of child menu entries, if any, under the given menu entry.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/menu-entry/HasChildren
|
||||
returnType: navigation.Menu
|
||||
signatures: [MENUENTRY.Children]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/menu-entry/HasChildren
|
||||
returnType: navigation.Menu
|
||||
signatures: [MENUENTRY.Children]
|
||||
---
|
||||
|
||||
Use the `Children` method when rendering a nested menu.
|
||||
|
||||
@@ -3,11 +3,12 @@ title: HasChildren
|
||||
description: Reports whether the given menu entry has child menu entries.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/menu-entry/Children
|
||||
returnType: bool
|
||||
signatures: [MENUENTRY.HasChildren]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/menu-entry/Children
|
||||
returnType: bool
|
||||
signatures: [MENUENTRY.HasChildren]
|
||||
---
|
||||
|
||||
Use the `HasChildren` method when rendering a nested menu.
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
---
|
||||
title: Identifier
|
||||
description: Returns the `identifier` property of the given menu entry.
|
||||
description: Returns the `identifier` property of the given menu entry.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.Identifier]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.Identifier]
|
||||
---
|
||||
|
||||
The `Identifier` method returns the `identifier` property of the menu entry. If you define the menu entry [automatically], it returns the page's section.
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
---
|
||||
title: KeyName
|
||||
description: Returns the `identifier` property of the given menu entry, falling back to its `name` property.
|
||||
description: Returns the `identifier` property of the given menu entry, falling back to its `name` property.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.KeyName]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.KeyName]
|
||||
---
|
||||
|
||||
In this menu definition, the second entry does not contain an `identifier`, so the `Identifier` method returns its `name` property instead:
|
||||
|
||||
@@ -3,12 +3,13 @@ title: Menu
|
||||
description: Returns the identifier of the menu that contains the given menu entry.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/IsMenuCurrent
|
||||
- methods/page/HasMenuCurrent
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.Menu]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/IsMenuCurrent
|
||||
- methods/page/HasMenuCurrent
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.Menu]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -3,10 +3,11 @@ title: Name
|
||||
description: Returns the `name` property of the given menu entry.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.Name]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.Name]
|
||||
---
|
||||
|
||||
If you define the menu entry [automatically], the `Name` method returns the page's [`LinkTitle`], falling back to its [`Title`].
|
||||
|
||||
@@ -3,10 +3,11 @@ title: Page
|
||||
description: Returns the Page object associated with the given menu entry.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: page.Page
|
||||
signatures: [MENUENTRY.Page]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: page.Page
|
||||
signatures: [MENUENTRY.Page]
|
||||
---
|
||||
|
||||
Regardless of how you [define menu entries], an entry associated with a page has access to its [methods].
|
||||
|
||||
@@ -3,12 +3,12 @@ title: PageRef
|
||||
description: Returns the `pageRef` property of the given menu entry.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- /methods/menu-entry/URL
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.PageRef]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- /methods/menu-entry/URL
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.PageRef]
|
||||
---
|
||||
|
||||
The use case for this method is rare.
|
||||
|
||||
@@ -3,10 +3,11 @@ title: Params
|
||||
description: Returns the `params` property of the given menu entry.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: maps.Params
|
||||
signatures: [MENUENTRY.Params]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: maps.Params
|
||||
signatures: [MENUENTRY.Params]
|
||||
---
|
||||
|
||||
When you define menu entries [in site configuration] or [in front matter], you can include a `params` key to attach additional information to the entry. For example:
|
||||
|
||||
@@ -3,10 +3,11 @@ title: Parent
|
||||
description: Returns the `parent` property of the given menu entry.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.Parent]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.Parent]
|
||||
---
|
||||
|
||||
With this menu definition:
|
||||
@@ -40,7 +41,7 @@ This template renders the nested menu, listing the `parent` property next each o
|
||||
{{ if .HasChildren }}
|
||||
<ul>
|
||||
{{ range .Children }}
|
||||
<li><a href="{{ .URL }}">{{ .Name }}</a> ({{ .Parent }})</li>
|
||||
<li><a href="{{ .URL }}">{{ .Name }}</a> ({{ .Parent }})</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
---
|
||||
title: Post
|
||||
description: Returns the `post` property of the given menu entry.
|
||||
description: Returns the `post` property of the given menu entry.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/menu-entry/Pre
|
||||
returnType: template.HTML
|
||||
signatures: [MENUENTRY.Post]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/menu-entry/Pre
|
||||
returnType: template.HTML
|
||||
signatures: [MENUENTRY.Post]
|
||||
---
|
||||
|
||||
{{% include "methods/menu-entry/_common/pre-post.md" %}}
|
||||
{{% include "/_common/menu-entries/pre-and-post.md" %}}
|
||||
@@ -1,13 +1,14 @@
|
||||
---
|
||||
title: Pre
|
||||
description: Returns the `pre` property of the given menu entry.
|
||||
description: Returns the `pre` property of the given menu entry.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/menu-entry/Post
|
||||
returnType: template.HTML
|
||||
signatures: [MENUENTRY.Pre]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/menu-entry/Post
|
||||
returnType: template.HTML
|
||||
signatures: [MENUENTRY.Pre]
|
||||
---
|
||||
|
||||
{{% include "methods/menu-entry/_common/pre-post.md" %}}
|
||||
{{% include "/_common/menu-entries/pre-and-post.md" %}}
|
||||
@@ -1,15 +1,16 @@
|
||||
---
|
||||
title: Title
|
||||
description: Returns the `title` property of the given menu entry.
|
||||
description: Returns the `title` property of the given menu entry.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.Title]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.Title]
|
||||
---
|
||||
|
||||
The `Title` method returns the `title` property of the given menu entry. If the `title` is not defined, and the menu entry resolves to a page, the `Title` returns the page [`Title`].
|
||||
The `Title` method returns the `title` property of the given menu entry. If the `title` is not defined, and the menu entry resolves to a page, the `Title` returns the page [`Title`].
|
||||
|
||||
[`Title`]: /methods/page/title/
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@ title: URL
|
||||
description: Returns the relative permalink of the page associated with the given menu entry, else its `url` property.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.URL]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [MENUENTRY.URL]
|
||||
---
|
||||
|
||||
For menu entries associated with a page, the `URL` method returns the page's [`RelPermalink`], otherwise it returns the entry's `url` property.
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
---
|
||||
title: Weight
|
||||
description: Returns the `weight` property of the given menu entry.
|
||||
description: Returns the `weight` property of the given menu entry.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: int
|
||||
signatures: [MENUENTRY.Weight]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: int
|
||||
signatures: [MENUENTRY.Weight]
|
||||
---
|
||||
|
||||
If you define the menu entry [automatically], the `Weight` method returns the page’s [`Weight`].
|
||||
If you define the menu entry [automatically], the `Weight` method returns the page's [`Weight`].
|
||||
|
||||
If you define the menu entry [in front matter] or [in site configuration], the `Weight` method returns the `weight` property, falling back to the page’s `Weight`.
|
||||
If you define the menu entry [in front matter] or [in site configuration], the `Weight` method returns the `weight` property, falling back to the page's `Weight`.
|
||||
|
||||
[`Weight`]: /methods/page/weight/
|
||||
[automatically]: /content-management/menus/#define-automatically
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
---
|
||||
cascade:
|
||||
_build:
|
||||
list: never
|
||||
publishResources: false
|
||||
render: never
|
||||
---
|
||||
|
||||
<!--
|
||||
Files within this headless branch bundle are Markdown snippets. Each file must contain front matter delimiters, though front matter fields are not required.
|
||||
|
||||
Include the rendered content using the "include" shortcode.
|
||||
-->
|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
_comment: Do not remove front matter.
|
||||
---
|
||||
|
||||
In this site configuration we enable rendering of [emoji shortcodes], and add emoji shortcodes before (pre) and after (post) each menu entry:
|
||||
|
||||
{{< code-toggle file=hugo >}}
|
||||
enableEmoji = true
|
||||
|
||||
[[menus.main]]
|
||||
name = 'About'
|
||||
pageRef = '/about'
|
||||
post = ':point_left:'
|
||||
pre = ':point_right:'
|
||||
weight = 10
|
||||
|
||||
[[menus.main]]
|
||||
name = 'Contact'
|
||||
pageRef = '/contact'
|
||||
post = ':arrow_left:'
|
||||
pre = ':arrow_right:'
|
||||
weight = 20
|
||||
{{< /code-toggle >}}
|
||||
|
||||
To render the menu:
|
||||
|
||||
```go-html-template
|
||||
<ul>
|
||||
{{ range .Site.Menus.main }}
|
||||
<li>
|
||||
{{ .Pre | markdownify }}
|
||||
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||
{{ .Post | markdownify }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
```
|
||||
|
||||
[emoji shortcodes]: /quick-reference/emojis/
|
||||
@@ -4,9 +4,4 @@ linkTitle: Menu entry
|
||||
description: Use these methods in your menu templates.
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: methods
|
||||
---
|
||||
|
||||
Use these methods in your menu templates.
|
||||
@@ -3,10 +3,11 @@ title: ByName
|
||||
description: Returns the given menu with its entries sorted by name.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: navigation.Menu
|
||||
signatures: [MENU.ByName]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: navigation.Menu
|
||||
signatures: [MENU.ByName]
|
||||
---
|
||||
|
||||
The `Sort` method returns the given menu with its entries sorted by `name`.
|
||||
|
||||
@@ -3,10 +3,11 @@ title: ByWeight
|
||||
description: Returns the given menu with its entries sorted by weight, then by name, then by identifier.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: navigation.Menu
|
||||
signatures: [MENU.ByWeight]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: navigation.Menu
|
||||
signatures: [MENU.ByWeight]
|
||||
---
|
||||
|
||||
The `ByWeight` method returns the given menu with its entries sorted by [`weight`](g), then by `name`, then by `identifier`. This is the default sort order.
|
||||
|
||||
@@ -3,10 +3,11 @@ title: Limit
|
||||
description: Returns the given menu, limited to the first N entries.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: navigation.Menu
|
||||
signatures: [MENU.Limit N]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: navigation.Menu
|
||||
signatures: [MENU.Limit N]
|
||||
---
|
||||
|
||||
The `Limit` method returns the given menu, limited to the first N entries.
|
||||
|
||||
@@ -3,10 +3,11 @@ title: Reverse
|
||||
description: Returns the given menu, reversing the sort order of its entries.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: navigation.Menu
|
||||
signatures: [MENU.Reverse]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: navigation.Menu
|
||||
signatures: [MENU.Reverse]
|
||||
---
|
||||
|
||||
The `Reverse` method returns the given menu, reversing the sort order of its entries.
|
||||
|
||||
@@ -4,9 +4,4 @@ linkTitle: Menu
|
||||
description: Use these methods when ranging through menu entries.
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: methods
|
||||
---
|
||||
|
||||
Use these methods when ranging through menu entries.
|
||||
@@ -3,10 +3,11 @@ title: Aliases
|
||||
description: Returns the URL aliases as defined in front matter.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: '[]string'
|
||||
signatures: [PAGE.Aliases]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: '[]string'
|
||||
signatures: [PAGE.Aliases]
|
||||
---
|
||||
|
||||
The `Aliases` method on a `Page` object returns the URL [aliases] as defined in front matter.
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
---
|
||||
title: AllTranslations
|
||||
description: Returns all translations of the given page, including the current language.
|
||||
description: Returns all translations of the given page, including the current language.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Translations
|
||||
- methods/page/IsTranslated
|
||||
- methods/page/TranslationKey
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.AllTranslations]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Translations
|
||||
- methods/page/IsTranslated
|
||||
- methods/page/TranslationKey
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.AllTranslations]
|
||||
---
|
||||
|
||||
With this site configuration:
|
||||
|
||||
@@ -3,20 +3,21 @@ title: AlternativeOutputFormats
|
||||
description: Returns a slice of OutputFormat objects, excluding the current output format, each representing one of the output formats enabled for the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/OutputFormats
|
||||
returnType: page.OutputFormats
|
||||
signatures: [PAGE.AlternativeOutputFormats]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/OutputFormats
|
||||
returnType: page.OutputFormats
|
||||
signatures: [PAGE.AlternativeOutputFormats]
|
||||
---
|
||||
|
||||
{{% glossary-term "output format" %}}
|
||||
|
||||
The `AlternativeOutputFormats` method on a `Page` object returns a slice of `OutputFormat` objects, excluding the current output format, each representing one of the output formats enabled for the given page.. See [details](/templates/output-formats/).
|
||||
The `AlternativeOutputFormats` method on a `Page` object returns a slice of `OutputFormat` objects, excluding the current output format, each representing one of the output formats enabled for the given page. See [details](/configuration/output-formats/).
|
||||
|
||||
## Methods
|
||||
|
||||
{{% include "methods/page/_common/output-format-methods.md" %}}
|
||||
{{% include "/_common/methods/page/output-format-methods.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
---
|
||||
title: Ancestors
|
||||
description: Returns a collection of Page objects, one for each ancestor section of the given page.
|
||||
description: Returns a collection of Page objects, one for each ancestor section of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/CurrentSection
|
||||
- methods/page/FirstSection
|
||||
- methods/page/InSection
|
||||
- methods/page/IsAncestor
|
||||
- methods/page/IsDescendant
|
||||
- methods/page/Parent
|
||||
- methods/page/Sections
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.Ancestors]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/CurrentSection
|
||||
- methods/page/FirstSection
|
||||
- methods/page/InSection
|
||||
- methods/page/IsAncestor
|
||||
- methods/page/IsDescendant
|
||||
- methods/page/Parent
|
||||
- methods/page/Sections
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.Ancestors]
|
||||
---
|
||||
|
||||
{{% glossary-term section %}}
|
||||
|
||||
With this content structure:
|
||||
|
||||
```text
|
||||
|
||||
@@ -3,10 +3,11 @@ title: BundleType
|
||||
description: Returns the bundle type of the given page, or an empty string if the page is not a page bundle.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [PAGE.BundleType]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [PAGE.BundleType]
|
||||
---
|
||||
|
||||
A page bundle is a directory that encapsulates both content and associated [resources](g). There are two types of page bundles: [leaf bundles](g) and [branch bundles](g). See [details](/content-management/page-bundles/).
|
||||
|
||||
@@ -3,11 +3,12 @@ title: CodeOwners
|
||||
description: Returns of slice of code owners for the given page, derived from the CODEOWNERS file in the root of the project directory.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/GitInfo
|
||||
returnType: '[]string'
|
||||
signatures: [PAGE.CodeOwners]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/GitInfo
|
||||
returnType: '[]string'
|
||||
signatures: [PAGE.CodeOwners]
|
||||
---
|
||||
|
||||
GitHub and GitLab support CODEOWNERS files. This file specifies the users responsible for developing and maintaining software and documentation. This definition can apply to the entire repository, specific directories, or to individual files. To learn more:
|
||||
|
||||
@@ -3,16 +3,17 @@ title: Content
|
||||
description: Returns the rendered content of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Summary
|
||||
- methods/page/ContentWithoutSummary
|
||||
- methods/page/RawContent
|
||||
- methods/page/Plain
|
||||
- methods/page/PlainWords
|
||||
- methods/page/RenderShortcodes
|
||||
returnType: template.HTML
|
||||
signatures: [PAGE.Content]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Summary
|
||||
- methods/page/ContentWithoutSummary
|
||||
- methods/page/RawContent
|
||||
- methods/page/Plain
|
||||
- methods/page/PlainWords
|
||||
- methods/page/RenderShortcodes
|
||||
returnType: template.HTML
|
||||
signatures: [PAGE.Content]
|
||||
---
|
||||
|
||||
The `Content` method on a `Page` object renders Markdown and shortcodes to HTML.
|
||||
|
||||
@@ -3,16 +3,17 @@ title: ContentWithoutSummary
|
||||
description: Returns the rendered content of the given page, excluding the content summary.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Content
|
||||
- methods/page/Summary
|
||||
- methods/page/RawContent
|
||||
- methods/page/Plain
|
||||
- methods/page/PlainWords
|
||||
- methods/page/RenderShortcodes
|
||||
returnType: template.HTML
|
||||
signatures: [PAGE.ContentWithoutSummary]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Content
|
||||
- methods/page/Summary
|
||||
- methods/page/RawContent
|
||||
- methods/page/Plain
|
||||
- methods/page/PlainWords
|
||||
- methods/page/RenderShortcodes
|
||||
returnType: template.HTML
|
||||
signatures: [PAGE.ContentWithoutSummary]
|
||||
---
|
||||
|
||||
{{< new-in 0.134.0 />}}
|
||||
|
||||
@@ -3,17 +3,18 @@ title: CurrentSection
|
||||
description: Returns the Page object of the section in which the given page resides.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Ancestors
|
||||
- methods/page/FirstSection
|
||||
- methods/page/InSection
|
||||
- methods/page/IsAncestor
|
||||
- methods/page/IsDescendant
|
||||
- methods/page/Parent
|
||||
- methods/page/Sections
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.CurrentSection]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Ancestors
|
||||
- methods/page/FirstSection
|
||||
- methods/page/InSection
|
||||
- methods/page/IsAncestor
|
||||
- methods/page/IsDescendant
|
||||
- methods/page/Parent
|
||||
- methods/page/Sections
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.CurrentSection]
|
||||
---
|
||||
|
||||
{{% glossary-term section %}}
|
||||
|
||||
@@ -3,11 +3,11 @@ title: Data
|
||||
description: Returns a unique data object for each page kind.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: page.Data
|
||||
signatures: [PAGE.Data]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: page.Data
|
||||
signatures: [PAGE.Data]
|
||||
---
|
||||
|
||||
The `Data` method on a `Page` object returns a unique data object for each [page kind](g).
|
||||
|
||||
@@ -3,13 +3,14 @@ title: Date
|
||||
description: Returns the date of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/ExpiryDate
|
||||
- methods/page/LastMod
|
||||
- methods/page/PublishDate
|
||||
returnType: time.Time
|
||||
signatures: [PAGE.Date]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/ExpiryDate
|
||||
- methods/page/LastMod
|
||||
- methods/page/PublishDate
|
||||
returnType: time.Time
|
||||
signatures: [PAGE.Date]
|
||||
---
|
||||
|
||||
Set the date in front matter:
|
||||
@@ -22,7 +23,7 @@ date = 2023-10-19T00:40:04-07:00
|
||||
{{< note >}}
|
||||
The date field in front matter is often considered to be the creation date, You can change its meaning, and its effect on your site, in the site configuration. See [details].
|
||||
|
||||
[details]: /getting-started/configuration/#configure-dates
|
||||
[details]: /configuration/front-matter/#dates
|
||||
{{< /note >}}
|
||||
|
||||
The date is a [time.Time] value. Format and localize the value with the [`time.Format`] function, or use it with any of the [time methods].
|
||||
@@ -34,6 +35,6 @@ The date is a [time.Time] value. Format and localize the value with the [`time.F
|
||||
In the example above we explicitly set the date in front matter. With Hugo's default configuration, the `Date` method returns the front matter value. This behavior is configurable, allowing you to set fallback values if the date is not defined in front matter. See [details].
|
||||
|
||||
[`time.Format`]: /functions/time/format/
|
||||
[details]: /getting-started/configuration/#configure-dates
|
||||
[details]: /configuration/front-matter/#dates
|
||||
[time methods]: /methods/time/
|
||||
[time.Time]: https://pkg.go.dev/time#Time
|
||||
@@ -3,11 +3,12 @@ title: Description
|
||||
description: Returns the description of the given page as defined in front matter.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Summary
|
||||
returnType: string
|
||||
signatures: [PAGE.Description]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Summary
|
||||
returnType: string
|
||||
signatures: [PAGE.Description]
|
||||
---
|
||||
|
||||
Conceptually different from a [content summary], a page description is typically used in metadata about the page.
|
||||
@@ -17,7 +18,7 @@ title = 'How to make spicy tuna hand rolls'
|
||||
description = 'Instructions for making spicy tuna hand rolls.'
|
||||
{{< /code-toggle >}}
|
||||
|
||||
{{< code file=layouts/baseof.html >}}
|
||||
{{< code file=layouts/baseof.html >}}
|
||||
<head>
|
||||
...
|
||||
<meta name="description" content="{{ .Description }}">
|
||||
|
||||
@@ -3,10 +3,11 @@ title: Draft
|
||||
description: Reports whether the given page is a draft as defined in front matter.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: bool
|
||||
signatures: [PAGE.Draft]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: bool
|
||||
signatures: [PAGE.Draft]
|
||||
---
|
||||
|
||||
By default, Hugo does not publish draft pages when you build your site. To include draft pages when you build your site, use the `--buildDrafts` command line flag.
|
||||
|
||||
@@ -3,17 +3,18 @@ title: Eq
|
||||
description: Reports whether two Page objects are equal.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: bool
|
||||
signatures: [PAGE1.Eq PAGE2]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: bool
|
||||
signatures: [PAGE1.Eq PAGE2]
|
||||
---
|
||||
|
||||
In this contrived example from a single template, we list all pages in the current section except for the current page.
|
||||
|
||||
```go-html-template
|
||||
{{ $currentPage := . }}
|
||||
{{ range .CurrentSection.Pages }}
|
||||
{{ range .CurrentSection.Pages }}
|
||||
{{ if not (.Eq $currentPage) }}
|
||||
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
|
||||
{{ end }}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
---
|
||||
title: ExpiryDate
|
||||
description: Returns the expiry date of the given page.
|
||||
description: Returns the expiry date of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Date
|
||||
- methods/page/LastMod
|
||||
- methods/page/PublishDate
|
||||
returnType: time.Time
|
||||
signatures: [PAGE.ExpiryDate]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Date
|
||||
- methods/page/LastMod
|
||||
- methods/page/PublishDate
|
||||
returnType: time.Time
|
||||
signatures: [PAGE.ExpiryDate]
|
||||
---
|
||||
|
||||
By default, Hugo excludes expired pages when building your site. To include expired pages, use the `--buildExpired` command line flag.
|
||||
@@ -30,6 +31,6 @@ The expiry date is a [time.Time] value. Format and localize the value with the [
|
||||
In the example above we explicitly set the expiry date in front matter. With Hugo's default configuration, the `ExpiryDate` method returns the front matter value. This behavior is configurable, allowing you to set fallback values if the expiry date is not defined in front matter. See [details].
|
||||
|
||||
[`time.Format`]: /functions/time/format/
|
||||
[details]: /getting-started/configuration/#configure-dates
|
||||
[details]: /configuration/front-matter/#dates
|
||||
[time methods]: /methods/time/
|
||||
[time.Time]: https://pkg.go.dev/time#Time
|
||||
@@ -3,21 +3,21 @@ title: File
|
||||
description: For pages backed by a file, returns file information for the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: hugolib.fileInfo
|
||||
signatures: [PAGE.File]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: hugolib.fileInfo
|
||||
signatures: [PAGE.File]
|
||||
---
|
||||
|
||||
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.
|
||||
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:
|
||||
|
||||
```text
|
||||
content/
|
||||
└── books/
|
||||
├── _index.md <-- the top level section page
|
||||
├── _index.md <-- the top-slevel section page
|
||||
├── book-1.md
|
||||
└── book-2.md
|
||||
```
|
||||
@@ -32,7 +32,7 @@ Code defensively by verifying file existence as shown in the examples below.
|
||||
The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend on the operating system.
|
||||
{{< /note >}}
|
||||
|
||||
###### BaseFileName
|
||||
### BaseFileName
|
||||
|
||||
(`string`) The file name, excluding the extension.
|
||||
|
||||
@@ -42,7 +42,7 @@ The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### ContentBaseName
|
||||
### ContentBaseName
|
||||
|
||||
(`string`) If the page is a branch or leaf bundle, the name of the containing directory, else the `TranslationBaseName`.
|
||||
|
||||
@@ -52,7 +52,7 @@ The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### Dir
|
||||
### Dir
|
||||
|
||||
(`string`) The file path, excluding the file name, relative to the `content` directory.
|
||||
|
||||
@@ -62,7 +62,7 @@ The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### Ext
|
||||
### Ext
|
||||
|
||||
(`string`) The file extension.
|
||||
|
||||
@@ -72,7 +72,7 @@ The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### Filename
|
||||
### Filename
|
||||
|
||||
(`string`) The absolute file path.
|
||||
|
||||
@@ -82,7 +82,7 @@ The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### IsContentAdapter
|
||||
### IsContentAdapter
|
||||
|
||||
{{< new-in 0.126.0 />}}
|
||||
|
||||
@@ -96,7 +96,7 @@ The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### LogicalName
|
||||
### LogicalName
|
||||
|
||||
(`string`) The file name.
|
||||
|
||||
@@ -106,7 +106,7 @@ The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### Path
|
||||
### Path
|
||||
|
||||
(`string`) The file path, relative to the `content` directory.
|
||||
|
||||
@@ -116,9 +116,9 @@ The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### Section
|
||||
### Section
|
||||
|
||||
(`string`) The name of the top level section in which the file resides.
|
||||
(`string`) The name of the top-level section in which the file resides.
|
||||
|
||||
```go-html-template
|
||||
{{ with .File }}
|
||||
@@ -126,7 +126,7 @@ The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### TranslationBaseName
|
||||
### TranslationBaseName
|
||||
|
||||
(`string`) The file name, excluding the extension and language identifier.
|
||||
|
||||
@@ -136,7 +136,7 @@ The path separators (slash or backslash) in `Path`, `Dir`, and `Filename` depend
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### UniqueID
|
||||
### UniqueID
|
||||
|
||||
(`string`) The MD5 hash of `.File.Path`.
|
||||
|
||||
@@ -184,7 +184,7 @@ UniqueID|15be14b...|186868f...|7d9159d...
|
||||
|
||||
Some of the pages on a site may not be backed by a file. For example:
|
||||
|
||||
- Top level section pages
|
||||
- Top-level section pages
|
||||
- Taxonomy pages
|
||||
- Term pages
|
||||
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
---
|
||||
title: FirstSection
|
||||
description: Returns the Page object of the top level section of which the given page is a descendant.
|
||||
description: Returns the Page object of the top-level section of which the given page is a descendant.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Ancestors
|
||||
- methods/page/CurrentSection
|
||||
- methods/page/InSection
|
||||
- methods/page/IsAncestor
|
||||
- methods/page/IsDescendant
|
||||
- methods/page/Parent
|
||||
- methods/page/Sections
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.FirstSection]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Ancestors
|
||||
- methods/page/CurrentSection
|
||||
- methods/page/InSection
|
||||
- methods/page/IsAncestor
|
||||
- methods/page/IsDescendant
|
||||
- methods/page/Parent
|
||||
- methods/page/Sections
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.FirstSection]
|
||||
---
|
||||
|
||||
{{% glossary-term section %}}
|
||||
@@ -49,7 +50,7 @@ content/
|
||||
└── _index.md <-- first section: home
|
||||
```
|
||||
|
||||
To link to the top level section of which the current page is a descendant:
|
||||
To link to the top-level section of which the current page is a descendant:
|
||||
|
||||
```go-html-template
|
||||
<a href="{{ .FirstSection.RelPermalink }}">{{ .FirstSection.LinkTitle }}</a>
|
||||
|
||||
@@ -3,12 +3,12 @@ title: Fragments
|
||||
description: Returns a data structure of the fragments in the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/TableOfContents
|
||||
returnType: tableofcontents.Fragments
|
||||
signatures: [PAGE.Fragments]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/TableOfContents
|
||||
returnType: tableofcontents.Fragments
|
||||
signatures: [PAGE.Fragments]
|
||||
---
|
||||
|
||||
In a URL, whether absolute or relative, the [fragment](g) links to an `id` attribute of an HTML element on the page.
|
||||
@@ -25,43 +25,53 @@ Use the `Fragments` method on a `Page` object to create a table of contents with
|
||||
|
||||
## Methods
|
||||
|
||||
Headings
|
||||
: (`slice`) A slice of maps of all headings on the page, with first-level keys for each heading. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
|
||||
### Headings
|
||||
|
||||
(`slice`) A slice of maps of all headings on the page, with first-level keys for each heading. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
|
||||
|
||||
```go-html-template
|
||||
<pre>{{ debug.Dump .Fragments.Headings }}</pre>
|
||||
```
|
||||
|
||||
HeadingsMap
|
||||
: (`map`) A nested map of all headings on the page. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
|
||||
### HeadingsMap
|
||||
|
||||
(`map`) A nested map of all headings on the page. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
|
||||
|
||||
```go-html-template
|
||||
<pre>{{ debug.Dump .Fragments.HeadingsMap }}</pre>
|
||||
```
|
||||
|
||||
Identifiers
|
||||
: (`slice`) A slice containing the `id` of each heading on the page. To inspect the data structure:
|
||||
### Identifiers
|
||||
|
||||
(`slice`) A slice containing the `id` attribute of each heading on the page. If so configured, will also contain the `id` attribute of each description term (i.e., `dt` element) on the page.
|
||||
|
||||
See [configure Markup](/configuration/markup/#parserautodefinitiontermid).
|
||||
|
||||
To inspect the data structure:
|
||||
|
||||
```go-html-template
|
||||
<pre>{{ debug.Dump .Fragments.Identifiers }}</pre>
|
||||
```
|
||||
|
||||
Identifiers.Contains ID
|
||||
: (`bool`) Reports whether one or more headings on the page has the given `id` attribute, useful for validating fragments within a link [render hook](g).
|
||||
### Identifiers.Contains ID
|
||||
|
||||
(`bool`) Reports whether one or more headings on the page has the given `id` attribute, useful for validating fragments within a link [render hook](g).
|
||||
|
||||
```go-html-template
|
||||
{{ .Fragments.Identifiers.Contains "section-2" }} → true
|
||||
```
|
||||
|
||||
Identifiers.Count ID
|
||||
: (`int`) The number of headings on a page with the given `id` attribute, useful for detecting duplicates.
|
||||
### Identifiers.Count ID
|
||||
|
||||
(`int`) The number of headings on a page with the given `id` attribute, useful for detecting duplicates.
|
||||
|
||||
```go-html-template
|
||||
{{ .Fragments.Identifiers.Count "section-2" }} → 1
|
||||
```
|
||||
|
||||
ToHTML
|
||||
: (`template.HTML`) Returns a TOC as a nested list, either ordered or unordered, identical to the HTML returned by the [`TableOfContents`] method. This method take three arguments: the start level (`int`), the end level (`int`), and a boolean (`true` to return an ordered list, `false` to return an unordered list).
|
||||
### ToHTML
|
||||
|
||||
(`template.HTML`) Returns a TOC as a nested list, either ordered or unordered, identical to the HTML returned by the [`TableOfContents`] method. This method take three arguments: the start level (`int`), the end level (`int`), and a boolean (`true` to return an ordered list, `false` to return an unordered list).
|
||||
|
||||
Use this method when you want to control the start level, end level, or list type independently from the table of contents settings in your site configuration.
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
---
|
||||
title: FuzzyWordCount
|
||||
description: Returns the number of words in the content of the given page, rounded up to the nearest multiple of 100.
|
||||
description: Returns the number of words in the content of the given page, rounded up to the nearest multiple of 100.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/WordCount
|
||||
- methods/page/ReadingTime
|
||||
returnType: int
|
||||
signatures: [PAGE.FuzzyWordCount]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/WordCount
|
||||
- methods/page/ReadingTime
|
||||
returnType: int
|
||||
signatures: [PAGE.FuzzyWordCount]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
---
|
||||
title: GetPage
|
||||
description: Returns a Page object from the given path.
|
||||
description: Returns a Page object from the given path.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/site/GetPage
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.GetPage PATH]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/site/GetPage
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.GetPage PATH]
|
||||
aliases: [/functions/getpage]
|
||||
---
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@ title: GetTerms
|
||||
description: Returns a collection of term pages for terms defined on the given page in the given taxonomy, ordered according to the sequence in which they appear in front matter.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.GetTerms TAXONOMY]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.GetTerms TAXONOMY]
|
||||
---
|
||||
|
||||
Given this front matter:
|
||||
|
||||
@@ -3,12 +3,12 @@ title: GitInfo
|
||||
description: Returns Git information related to the last commit of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/CodeOwners
|
||||
returnType: source.GitInfo
|
||||
signatures: [PAGE.GitInfo]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/CodeOwners
|
||||
returnType: source.GitInfo
|
||||
signatures: [PAGE.GitInfo]
|
||||
---
|
||||
|
||||
The `GitInfo` method on a `Page` object returns an object with additional methods.
|
||||
@@ -38,12 +38,12 @@ When you set `enableGitInfo` to `true`, or enable the feature with the command l
|
||||
|
||||
This is configurable. See [details].
|
||||
|
||||
[details]: /getting-started/configuration/#configure-dates
|
||||
[details]: /configuration/front-matter/#dates
|
||||
{{< /note >}}
|
||||
|
||||
## Methods
|
||||
|
||||
###### AbbreviatedHash
|
||||
### AbbreviatedHash
|
||||
|
||||
(`string`) The abbreviated commit hash.
|
||||
|
||||
@@ -53,7 +53,7 @@ This is configurable. See [details].
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### AuthorDate
|
||||
### AuthorDate
|
||||
|
||||
(`time.Time`) The author date.
|
||||
|
||||
@@ -63,7 +63,7 @@ This is configurable. See [details].
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### AuthorEmail
|
||||
### AuthorEmail
|
||||
|
||||
(`string`) The author's email address, respecting [gitmailmap].
|
||||
|
||||
@@ -73,7 +73,7 @@ This is configurable. See [details].
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### AuthorName
|
||||
### AuthorName
|
||||
|
||||
(`string`) The author's name, respecting [gitmailmap].
|
||||
|
||||
@@ -83,7 +83,7 @@ This is configurable. See [details].
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### CommitDate
|
||||
### CommitDate
|
||||
|
||||
(`time.Time`) The commit date.
|
||||
|
||||
@@ -93,7 +93,7 @@ This is configurable. See [details].
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### Hash
|
||||
### Hash
|
||||
|
||||
(`string`) The commit hash.
|
||||
|
||||
@@ -103,7 +103,7 @@ This is configurable. See [details].
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### Subject
|
||||
### Subject
|
||||
|
||||
(`string`) The commit message subject.
|
||||
|
||||
@@ -113,7 +113,7 @@ This is configurable. See [details].
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
###### Body
|
||||
### Body
|
||||
|
||||
(`string`) The commit message body.
|
||||
|
||||
@@ -131,27 +131,27 @@ You can change this behavior in your [site configuration].
|
||||
|
||||
[git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
|
||||
[gitmailmap]: https://git-scm.com/docs/gitmailmap
|
||||
[site configuration]: /getting-started/configuration/#configure-front-matter
|
||||
[site configuration]: /configuration/front-matter/
|
||||
|
||||
## Hosting considerations
|
||||
|
||||
When hosting your site in a CI/CD environment, the step that clones your project repository must perform a deep clone. If the clone is shallow, the Git information for a given file may not be accurate---it may reflect the most recent repository commit, not the commit that last modified the file.
|
||||
|
||||
Some providers perform deep clones by default, others allow you to configure the clone depth, and some providers only perform shallow clones.
|
||||
Some providers perform deep clones by default, others allow you to configure the clone depth, and some only perform shallow clones.
|
||||
|
||||
Hosting service | Default clone depth | Configurable
|
||||
:-- | :-- | :--
|
||||
AWS Amplify | Deep | N/A
|
||||
Cloudflare Pages | Shallow | Yes [^CFP]
|
||||
Cloudflare Pages | Shallow | Yes [^1]
|
||||
DigitalOcean App Platform | Deep | N/A
|
||||
GitHub Pages | Shallow | Yes [^GHP]
|
||||
GitLab Pages | Shallow | Yes [^GLP]
|
||||
GitHub Pages | Shallow | Yes [^2]
|
||||
GitLab Pages | Shallow | Yes [^3]
|
||||
Netlify | Deep | N/A
|
||||
Render | Shallow | No
|
||||
Vercel | Shallow | No
|
||||
|
||||
[^CFP]: To configure a Cloudflare Pages site for deep cloning, preface the site's normal Hugo build command with `git fetch --unshallow &&` (*e.g.*, `git fetch --unshallow && hugo`).
|
||||
[^1]: To configure a Cloudflare Pages site for deep cloning, run `git fetch --unshallow` before building the site.
|
||||
|
||||
[^GHP]: You can configure the GitHub Action to do a deep clone by specifying `fetch-depth: 0` in the applicable "checkout" step of your workflow file, as shown in the Hugo documentation's [example workflow file](/hosting-and-deployment/hosting-on-github/#procedure).
|
||||
[^2]: You can configure the GitHub Action to do a deep clone by specifying `fetch-depth: 0` in the applicable "checkout" step of your workflow file, as shown in the Hugo documentation's [example workflow file](/host-and-deploy/host-on-github-pages/#procedure).
|
||||
|
||||
[^GLP]: You can configure the GitLab Runner's clone depth [as explained in the GitLab documentation](https://docs.gitlab.com/ee/ci/large_repositories/#shallow-cloning); see also the Hugo documentation's [example workflow file](/hosting-and-deployment/hosting-on-gitlab/#configure-gitlab-cicd).
|
||||
[^3]: You can configure the GitLab Runner's clone depth [as explained in the GitLab documentation](https://docs.gitlab.com/ee/ci/large_repositories/#shallow-cloning); see also the Hugo documentation's [example workflow file](/host-and-deploy/host-on-gitlab-pages/#configure-gitlab-cicd).
|
||||
@@ -3,11 +3,12 @@ title: HasMenuCurrent
|
||||
description: Reports whether the given Page object matches the Page object associated with one of the child menu entries under the given menu entry in the given menu.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/IsMenuCurrent
|
||||
returnType: bool
|
||||
signatures: [PAGE.HasMenuCurrent MENU MENUENTRY]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/IsMenuCurrent
|
||||
returnType: bool
|
||||
signatures: [PAGE.HasMenuCurrent MENU MENUENTRY]
|
||||
aliases: [/functions/hasmenucurrent]
|
||||
---
|
||||
|
||||
|
||||
@@ -3,17 +3,18 @@ title: HasShortcode
|
||||
description: Reports whether the given shortcode is called by the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: bool
|
||||
signatures: [PAGE.HasShortcode NAME]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: bool
|
||||
signatures: [PAGE.HasShortcode NAME]
|
||||
---
|
||||
|
||||
By example, let's use [Plotly] to render a chart:
|
||||
|
||||
[Plotly]: https://plotly.com/javascript/
|
||||
|
||||
{{< code file=contents/example.md lang=markdown >}}
|
||||
{{< code file=contents/example.md lang=text >}}
|
||||
{{</* plotly */>}}
|
||||
{
|
||||
"data": [
|
||||
@@ -29,7 +30,7 @@ By example, let's use [Plotly] to render a chart:
|
||||
|
||||
The shortcode is simple:
|
||||
|
||||
{{< code file=layouts/shortcodes/plotly.html >}}
|
||||
{{< code file=layouts/shortcodes/plotly.html >}}
|
||||
{{ $id := printf "plotly-%02d" .Ordinal }}
|
||||
<div id="{{ $id }}"></div>
|
||||
<script>
|
||||
@@ -39,7 +40,7 @@ The shortcode is simple:
|
||||
|
||||
Now we can selectively load the required JavaScript on pages that call the "plotly" shortcode:
|
||||
|
||||
{{< code file=layouts/baseof.html >}}
|
||||
{{< code file=layouts/baseof.html >}}
|
||||
<head>
|
||||
...
|
||||
{{ if .HasShortcode "plotly" }}
|
||||
|
||||
@@ -3,16 +3,17 @@ title: HeadingsFiltered
|
||||
description: Returns a slice of headings for each page related to the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/pages/Related
|
||||
- methods/page/Fragments
|
||||
returnType: tableofcontents.Headings
|
||||
signatures: [PAGE.HeadingsFiltered]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/pages/Related
|
||||
- methods/page/Fragments
|
||||
returnType: tableofcontents.Headings
|
||||
signatures: [PAGE.HeadingsFiltered]
|
||||
---
|
||||
|
||||
Use in conjunction with the [`Related`] method on a [`Pages`] object. See [details].
|
||||
|
||||
[`Pages`]: /methods/pages/
|
||||
[`Related`]: /methods/pages/related/
|
||||
[details]: /content-management/related/#index-content-headings-in-related-content
|
||||
[details]: /content-management/related-content/#index-content-headings
|
||||
@@ -3,23 +3,25 @@ title: InSection
|
||||
description: Reports whether the given page is in the given section.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Ancestors
|
||||
- methods/page/CurrentSection
|
||||
- methods/page/FirstSection
|
||||
- methods/page/IsAncestor
|
||||
- methods/page/IsDescendant
|
||||
- methods/page/Parent
|
||||
- methods/page/Sections
|
||||
returnType: bool
|
||||
signatures: [PAGE.InSection SECTION]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Ancestors
|
||||
- methods/page/CurrentSection
|
||||
- methods/page/FirstSection
|
||||
- methods/page/IsAncestor
|
||||
- methods/page/IsDescendant
|
||||
- methods/page/Parent
|
||||
- methods/page/Sections
|
||||
returnType: bool
|
||||
signatures: [PAGE.InSection SECTION]
|
||||
---
|
||||
|
||||
{{% glossary-term section %}}
|
||||
|
||||
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.
|
||||
|
||||
{{% glossary-term section %}}
|
||||
|
||||
|
||||
With this content structure:
|
||||
|
||||
|
||||
@@ -3,22 +3,20 @@ title: IsAncestor
|
||||
description: Reports whether PAGE1 is an ancestor of PAGE2.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Ancestors
|
||||
- methods/page/CurrentSection
|
||||
- methods/page/FirstSection
|
||||
- methods/page/InSection
|
||||
- methods/page/IsDescendant
|
||||
- methods/page/Parent
|
||||
- methods/page/Sections
|
||||
returnType: bool
|
||||
signatures: [PAGE1.IsAncestor PAGE2]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Ancestors
|
||||
- methods/page/CurrentSection
|
||||
- methods/page/FirstSection
|
||||
- methods/page/InSection
|
||||
- methods/page/IsDescendant
|
||||
- methods/page/Parent
|
||||
- methods/page/Sections
|
||||
returnType: bool
|
||||
signatures: [PAGE1.IsAncestor PAGE2]
|
||||
---
|
||||
|
||||
{{% glossary-term section %}}
|
||||
|
||||
With this content structure:
|
||||
|
||||
```text
|
||||
|
||||
@@ -3,21 +3,20 @@ title: IsDescendant
|
||||
description: Reports whether PAGE1 is a descendant of PAGE2.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Ancestors
|
||||
- methods/page/CurrentSection
|
||||
- methods/page/FirstSection
|
||||
- methods/page/InSection
|
||||
- methods/page/IsAncestor
|
||||
- methods/page/Parent
|
||||
- methods/page/Sections
|
||||
returnType: bool
|
||||
signatures: [PAGE1.IsDescendant PAGE2]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Ancestors
|
||||
- methods/page/CurrentSection
|
||||
- methods/page/FirstSection
|
||||
- methods/page/InSection
|
||||
- methods/page/IsAncestor
|
||||
- methods/page/Parent
|
||||
- methods/page/Sections
|
||||
returnType: bool
|
||||
signatures: [PAGE1.IsDescendant PAGE2]
|
||||
---
|
||||
|
||||
{{% glossary-term section %}}
|
||||
|
||||
With this content structure:
|
||||
|
||||
```text
|
||||
|
||||
@@ -3,13 +3,14 @@ title: IsHome
|
||||
description: Reports whether the given page is the home page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/IsNode
|
||||
- methods/page/IsPage
|
||||
- methods/page/IsSection
|
||||
returnType: bool
|
||||
signatures: [PAGE.IsHome]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/IsNode
|
||||
- methods/page/IsPage
|
||||
- methods/page/IsSection
|
||||
returnType: bool
|
||||
signatures: [PAGE.IsHome]
|
||||
---
|
||||
|
||||
The `IsHome` method on a `Page` object returns `true` if the [page kind](g) is `home`.
|
||||
|
||||
@@ -3,11 +3,12 @@ title: IsMenuCurrent
|
||||
description: Reports whether the given Page object matches the Page object associated with the given menu entry in the given menu.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/HasMenuCurrent
|
||||
returnType: bool
|
||||
signatures: [PAGE.IsMenuCurrent MENU MENUENTRY]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/HasMenuCurrent
|
||||
returnType: bool
|
||||
signatures: [PAGE.IsMenuCurrent MENU MENUENTRY]
|
||||
aliases: [/functions/ismenucurrent]
|
||||
---
|
||||
|
||||
|
||||
@@ -3,13 +3,14 @@ title: IsNode
|
||||
description: Reports whether the given page is a node.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/IsHome
|
||||
- methods/page/IsPage
|
||||
- methods/page/IsSection
|
||||
returnType: bool
|
||||
signatures: [PAGE.IsNode]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/IsHome
|
||||
- methods/page/IsPage
|
||||
- methods/page/IsSection
|
||||
returnType: bool
|
||||
signatures: [PAGE.IsNode]
|
||||
---
|
||||
|
||||
The `IsNode` method on a `Page` object returns `true` if the [page kind](g) is `home`, `section`, `taxonomy`, or `term`.
|
||||
|
||||
@@ -3,13 +3,14 @@ title: IsPage
|
||||
description: Reports whether the given page is a regular page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/IsHome
|
||||
- methods/page/IsNode
|
||||
- methods/page/IsSection
|
||||
returnType: bool
|
||||
signatures: [PAGE.IsPage]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/IsHome
|
||||
- methods/page/IsNode
|
||||
- methods/page/IsSection
|
||||
returnType: bool
|
||||
signatures: [PAGE.IsPage]
|
||||
---
|
||||
|
||||
The `IsPage` method on a `Page` object returns `true` if the [page kind](g) is `page`.
|
||||
|
||||
@@ -3,13 +3,14 @@ title: IsSection
|
||||
description: Reports whether the given page is a section page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/IsHome
|
||||
- methods/page/IsNode
|
||||
- methods/page/IsPage
|
||||
returnType: bool
|
||||
signatures: [PAGE.IsSection]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/IsHome
|
||||
- methods/page/IsNode
|
||||
- methods/page/IsPage
|
||||
returnType: bool
|
||||
signatures: [PAGE.IsSection]
|
||||
---
|
||||
|
||||
The `IsSection` method on a `Page` object returns `true` if the [page kind](g) is `section`.
|
||||
|
||||
@@ -3,13 +3,14 @@ title: IsTranslated
|
||||
description: Reports whether the given page has one or more translations.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Translations
|
||||
- methods/page/AllTranslations
|
||||
- methods/page/TranslationKey
|
||||
returnType: bool
|
||||
signatures: [PAGE.IsTranslated]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Translations
|
||||
- methods/page/AllTranslations
|
||||
- methods/page/TranslationKey
|
||||
returnType: bool
|
||||
signatures: [PAGE.IsTranslated]
|
||||
---
|
||||
|
||||
With this site configuration:
|
||||
|
||||
@@ -3,15 +3,16 @@ title: Keywords
|
||||
description: Returns a slice of keywords as defined in front matter.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: '[]string'
|
||||
signatures: [PAGE.Keywords]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: '[]string'
|
||||
signatures: [PAGE.Keywords]
|
||||
---
|
||||
|
||||
By default, Hugo evaluates the keywords when creating collections of [related content].
|
||||
|
||||
[related content]: /content-management/related/
|
||||
[related content]: /content-management/related-content/
|
||||
|
||||
{{< code-toggle file=content/recipes/sushi.md fm=true >}}
|
||||
title = 'How to make spicy tuna hand rolls'
|
||||
|
||||
@@ -3,11 +3,12 @@ title: Kind
|
||||
description: Returns the kind of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Type
|
||||
returnType: string
|
||||
signatures: [PAGE.Kind]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Type
|
||||
returnType: string
|
||||
signatures: [PAGE.Kind]
|
||||
---
|
||||
|
||||
The [page kind](g) is one of `home`, `page`, `section`, `taxonomy`, or `term`.
|
||||
|
||||
@@ -3,11 +3,12 @@ title: Language
|
||||
description: Returns the language object for the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/site/Language
|
||||
returnType: langs.Language
|
||||
signatures: [PAGE.Language]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/site/Language
|
||||
returnType: langs.Language
|
||||
signatures: [PAGE.Language]
|
||||
---
|
||||
|
||||
The `Language` method on a `Page` object returns the language object for the given page. The language object points to the language definition in the site configuration.
|
||||
@@ -26,7 +27,7 @@ languageName = 'Deutsch'
|
||||
weight = 2
|
||||
{{< /code-toggle >}}
|
||||
|
||||
###### Lang
|
||||
### Lang
|
||||
|
||||
(`string`) The language tag as defined by [RFC 5646].
|
||||
|
||||
@@ -34,7 +35,7 @@ weight = 2
|
||||
{{ .Language.Lang }} → de
|
||||
```
|
||||
|
||||
###### LanguageCode
|
||||
### LanguageCode
|
||||
|
||||
(`string`) The language code from the site configuration. Falls back to `Lang` if not defined.
|
||||
|
||||
@@ -42,7 +43,7 @@ weight = 2
|
||||
{{ .Language.LanguageCode }} → de-DE
|
||||
```
|
||||
|
||||
###### LanguageDirection
|
||||
### LanguageDirection
|
||||
|
||||
(`string`) The language direction from the site configuration, either `ltr` or `rtl`.
|
||||
|
||||
@@ -50,7 +51,7 @@ weight = 2
|
||||
{{ .Language.LanguageDirection }} → ltr
|
||||
```
|
||||
|
||||
###### LanguageName
|
||||
### LanguageName
|
||||
|
||||
(`string`) The language name from the site configuration.
|
||||
|
||||
@@ -58,7 +59,7 @@ weight = 2
|
||||
{{ .Language.LanguageName }} → Deutsch
|
||||
```
|
||||
|
||||
###### Weight
|
||||
### Weight
|
||||
|
||||
(`int`) The language weight from the site configuration which determines its order in the slice of languages returned by the `Languages` method on a `Site` object.
|
||||
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
---
|
||||
title: Lastmod
|
||||
description: Returns the last modification date of the given page.
|
||||
description: Returns the last modification date of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Date
|
||||
- methods/page/ExpiryDate
|
||||
- methods/page/PublishDate
|
||||
- methods/page/GitInfo
|
||||
returnType: time.Time
|
||||
signatures: [PAGE.Lastmod]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Date
|
||||
- methods/page/ExpiryDate
|
||||
- methods/page/PublishDate
|
||||
- methods/page/GitInfo
|
||||
returnType: time.Time
|
||||
signatures: [PAGE.Lastmod]
|
||||
---
|
||||
|
||||
Set the last modification date in front matter:
|
||||
@@ -35,6 +36,6 @@ Learn more about [date configuration].
|
||||
|
||||
[`gitinfo`]: /methods/page/gitinfo/
|
||||
[`time.format`]: /functions/time/format/
|
||||
[date configuration]: /getting-started/configuration/#configure-dates
|
||||
[date configuration]: /configuration/front-matter/#dates
|
||||
[time methods]: /methods/time/
|
||||
[time.time]: https://pkg.go.dev/time#time
|
||||
[time.time]: https://pkg.go.dev/time#Time
|
||||
@@ -3,11 +3,12 @@ title: Layout
|
||||
description: Returns the layout for the given page as defined in front matter.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Type
|
||||
returnType: string
|
||||
signatures: [PAGE.Layout]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Type
|
||||
returnType: string
|
||||
signatures: [PAGE.Layout]
|
||||
---
|
||||
|
||||
Specify the `layout` field in front matter to target a particular template. See [details].
|
||||
|
||||
@@ -3,11 +3,12 @@ title: Len
|
||||
description: Returns the length, in bytes, of the rendered content of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Content
|
||||
returnType: int
|
||||
signatures: [PAGE.Len]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Content
|
||||
returnType: int
|
||||
signatures: [PAGE.Len]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
|
||||
@@ -3,11 +3,12 @@ title: LinkTitle
|
||||
description: Returns the link title of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Title
|
||||
returnType: string
|
||||
signatures: [PAGE.LinkTitle]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Title
|
||||
returnType: string
|
||||
signatures: [PAGE.LinkTitle]
|
||||
---
|
||||
|
||||
The `LinkTitle` method returns the `linkTitle` field as defined in front matter, falling back to the value returned by the [`Title`] method.
|
||||
|
||||
@@ -3,15 +3,16 @@ title: Next
|
||||
description: Returns the next page in a site's collection of regular pages, relative to the current page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Prev
|
||||
- methods/page/NextInSection
|
||||
- methods/page/PrevInSection
|
||||
- methods/pages/Next
|
||||
- methods/pages/Prev
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.Next]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Prev
|
||||
- methods/page/NextInSection
|
||||
- methods/page/PrevInSection
|
||||
- methods/pages/Next
|
||||
- methods/pages/Prev
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.Next]
|
||||
---
|
||||
|
||||
{{% include "methods/page/_common/next-and-prev.md" %}}
|
||||
{{% include "/_common/methods/page/next-and-prev.md" %}}
|
||||
@@ -1,15 +1,16 @@
|
||||
---
|
||||
title: NextInSection
|
||||
description: Returns the next regular page in a section, relative to the given page.
|
||||
description: Returns the next regular page in a section, relative to the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/PrevInSection
|
||||
- methods/pages/Next
|
||||
- methods/pages/Prev
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.NextInSection]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/PrevInSection
|
||||
- methods/pages/Next
|
||||
- methods/pages/Prev
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.NextInSection]
|
||||
---
|
||||
|
||||
{{% include "methods/page/_common/nextinsection-and-previnsection.md" %}}
|
||||
{{% include "/_common/methods/page/nextinsection-and-previnsection.md" %}}
|
||||
@@ -3,21 +3,21 @@ title: OutputFormats
|
||||
description: Returns a slice of OutputFormat objects, each representing one of the output formats enabled for the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/AlternativeOutputFormats
|
||||
returnType: '[]OutputFormat'
|
||||
signatures: [PAGE.OutputFormats]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/AlternativeOutputFormats
|
||||
returnType: '[]OutputFormat'
|
||||
signatures: [PAGE.OutputFormats]
|
||||
---
|
||||
|
||||
{{% glossary-term "output format" %}}
|
||||
|
||||
The `OutputFormats` method on a `Page` object returns a slice of `OutputFormat` objects, each representing one of the output formats enabled for the given page. See [details](/templates/output-formats/).
|
||||
The `OutputFormats` method on a `Page` object returns a slice of `OutputFormat` objects, each representing one of the output formats enabled for the given page. See [details](/configuration/output-formats/).
|
||||
|
||||
## Methods
|
||||
|
||||
{{% include "methods/page/_common/output-format-methods.md" %}}
|
||||
{{% include "/_common/methods/page/output-format-methods.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
@@ -37,4 +37,4 @@ On the site's home page, Hugo renders this to:
|
||||
|
||||
Please see the [link to output formats] section to understand the importance of the construct above.
|
||||
|
||||
[link to output formats]: /templates/output-formats/#link-to-output-formats
|
||||
[link to output formats]: /configuration/output-formats/#link-to-output-formats
|
||||
@@ -3,27 +3,28 @@ title: Page
|
||||
description: Returns the Page object of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.Page]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.Page]
|
||||
---
|
||||
|
||||
This is a convenience method, useful within partial templates that are called from both [shortcodes](g) and page templates.
|
||||
|
||||
{{< code file=layouts/shortcodes/foo.html >}}
|
||||
{{< code file=layouts/shortcodes/foo.html >}}
|
||||
{{ partial "my-partial.html" . }}
|
||||
{{< /code >}}
|
||||
|
||||
When the shortcode calls the partial, it passes the current [context](g) (the dot). The context includes identifiers such as `Page`, `Params`, `Inner`, and `Name`.
|
||||
|
||||
{{< code file=layouts/_default/single.html >}}
|
||||
{{< code file=layouts/_default/single.html >}}
|
||||
{{ partial "my-partial.html" . }}
|
||||
{{< /code >}}
|
||||
|
||||
When the page template calls the partial, it also passes the current context (the dot). But in this case, the dot _is_ the `Page` object.
|
||||
|
||||
{{< code file=layouts/partials/my-partial.html >}}
|
||||
{{< code file=layouts/partials/my-partial.html >}}
|
||||
The page title is: {{ .Page.Title }}
|
||||
{{< /code >}}
|
||||
|
||||
|
||||
@@ -3,15 +3,16 @@ title: Pages
|
||||
description: Returns a collection of regular pages within the current section, and section pages of immediate descendant sections.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/RegularPages
|
||||
- methods/page/RegularPagesRecursive
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.Pages]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/RegularPages
|
||||
- methods/page/RegularPagesRecursive
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.Pages]
|
||||
---
|
||||
|
||||
The `Pages` method on a `Page` object is available to these [page kinds](g): `home`, `section`, `taxonomy`, and `term`. The templates for these page kinds receive a page [collection](g) in [context](g).
|
||||
The `Pages` method on a `Page` object is available to these [page kinds](g): `home`, `section`, `taxonomy`, and `term`. The templates for these page kinds receive a page [collection](g) in [context](g), in the [default sort order](g).
|
||||
|
||||
Range through the page collection in your template:
|
||||
|
||||
|
||||
@@ -3,18 +3,19 @@ title: Paginate
|
||||
description: Paginates a collection of pages.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Paginator
|
||||
returnType: page.Pager
|
||||
signatures: ['PAGE.Paginate COLLECTION [N]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Paginator
|
||||
returnType: page.Pager
|
||||
signatures: ['PAGE.Paginate COLLECTION [N]']
|
||||
---
|
||||
|
||||
Pagination is the process of splitting a list page into two or more pagers, where each pager contains a subset of the page collection and navigation links to other pagers.
|
||||
|
||||
By default, the number of elements on each pager is determined by your [site configuration]. The default is `10`. Override that value by providing a second argument, an integer, when calling the `Paginate` method.
|
||||
|
||||
[site configuration]: /getting-started/configuration/#pagination
|
||||
[site configuration]: /configuration/pagination/
|
||||
|
||||
{{< note >}}
|
||||
There is also a `Paginator` method on `Page` objects, but it can neither filter nor sort the page collection.
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
---
|
||||
title: Paginator
|
||||
description: Paginates the collection of regular pages received in context.
|
||||
description: Paginates the collection of regular pages received in context.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Paginate
|
||||
returnType: page.Pager
|
||||
signatures: [PAGE.Paginator]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Paginate
|
||||
returnType: page.Pager
|
||||
signatures: [PAGE.Paginator]
|
||||
---
|
||||
|
||||
Pagination is the process of splitting a list page into two or more pagers, where each pager contains a subset of the page collection and navigation links to other pagers.
|
||||
|
||||
The number of elements on each pager is determined by your [site configuration]. The default is `10`.
|
||||
|
||||
[site configuration]: /getting-started/configuration/#pagination
|
||||
[site configuration]: /configuration/pagination/
|
||||
|
||||
You can invoke pagination on the [home template], [section templates], [taxonomy templates], and [term templates]. Each of these receives a collection of regular pages in [context](g). When you invoke the `Paginator` method, it paginates the page collection received in context.
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@ title: Param
|
||||
description: Returns a page parameter with the given key, falling back to a site parameter if present.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: any
|
||||
signatures: [PAGE.Param KEY]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related: []
|
||||
returnType: any
|
||||
signatures: [PAGE.Param KEY]
|
||||
aliases: [/functions/param]
|
||||
---
|
||||
|
||||
|
||||
@@ -3,13 +3,14 @@ title: Params
|
||||
description: Returns a map of custom parameters as defined in the front matter of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/collections/IndexFunction
|
||||
- methods/site/Params
|
||||
- methods/page/Param
|
||||
returnType: maps.Params
|
||||
signatures: [PAGE.Params]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- functions/collections/IndexFunction
|
||||
- methods/site/Params
|
||||
- methods/page/Param
|
||||
returnType: maps.Params
|
||||
signatures: [PAGE.Params]
|
||||
---
|
||||
|
||||
With this front matter:
|
||||
|
||||
@@ -3,17 +3,18 @@ title: Parent
|
||||
description: Returns the Page object of the parent section of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Ancestors
|
||||
- methods/page/CurrentSection
|
||||
- methods/page/FirstSection
|
||||
- methods/page/InSection
|
||||
- methods/page/IsAncestor
|
||||
- methods/page/IsDescendant
|
||||
- methods/page/Sections
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.Parent]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Ancestors
|
||||
- methods/page/CurrentSection
|
||||
- methods/page/FirstSection
|
||||
- methods/page/InSection
|
||||
- methods/page/IsAncestor
|
||||
- methods/page/IsDescendant
|
||||
- methods/page/Sections
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.Parent]
|
||||
---
|
||||
|
||||
{{% glossary-term section %}}
|
||||
|
||||
@@ -3,25 +3,25 @@ title: Path
|
||||
description: Returns the logical path of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/File
|
||||
- methods/page/RelPermalink
|
||||
returnType: string
|
||||
signatures: [PAGE.Path]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/File
|
||||
- methods/page/RelPermalink
|
||||
returnType: string
|
||||
signatures: [PAGE.Path]
|
||||
---
|
||||
|
||||
{{< 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.
|
||||
The `Path` method on a `Page` object returns the logical path of the given page, regardless of whether the page is backed by a file.
|
||||
|
||||
{{% glossary-term "logical path" %}}
|
||||
|
||||
```go-html-template
|
||||
{{ .Path }} → /posts/post-1
|
||||
```
|
||||
|
||||
This value is neither a file path nor a relative URL. It is a logical identifier for each page, independent of content format, language, and URL modifiers.
|
||||
|
||||
{{< note >}}
|
||||
Beginning with the release of [v0.92.0] in January 2022, Hugo emitted a warning whenever calling the `Path` method. The warning indicated that this method would change in a future release.
|
||||
|
||||
@@ -31,13 +31,6 @@ The meaning of, and value returned by, the `Path` method on a `Page` object chan
|
||||
[v0.123.0]: https://github.com/gohugoio/hugo/releases/tag/v0.123.0
|
||||
{{< /note >}}
|
||||
|
||||
To determine the logical path for pages backed by a file, Hugo starts with the file path, relative to the `content` directory, and then:
|
||||
|
||||
1. Strips the file extension
|
||||
1. Strips the language identifier
|
||||
1. Converts the result to lower case
|
||||
1. Replaces spaces with hyphens
|
||||
|
||||
The value returned by the `Path` method on a `Page` object is independent of content format, language, and URL modifiers such as the `slug` and `url` front matter fields.
|
||||
|
||||
## Examples
|
||||
@@ -101,10 +94,10 @@ Methods|Functions|Shortcodes
|
||||
:--|:--|:--
|
||||
[`Site.GetPage`]|[`urls.Ref`]|[`ref`]
|
||||
[`Page.GetPage`]|[`urls.RelRef`]|[`relref`]
|
||||
[`Page.Ref`]||
|
||||
[`Page.RelRef`]||
|
||||
[`Shortcode.Ref`]||
|
||||
[`Shortcode.RelRef`]||
|
||||
[`Page.Ref`]|||
|
||||
[`Page.RelRef`]|||
|
||||
[`Shortcode.Ref`]|||
|
||||
[`Shortcode.RelRef`]|||
|
||||
|
||||
[`urls.Ref`]: /functions/urls/ref/
|
||||
[`urls.RelRef`]: /functions/urls/relref/
|
||||
|
||||
@@ -3,11 +3,12 @@ title: Permalink
|
||||
description: Returns the permalink of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/RelPermalink
|
||||
returnType: string
|
||||
signatures: [PAGE.Permalink]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/RelPermalink
|
||||
returnType: string
|
||||
signatures: [PAGE.Permalink]
|
||||
---
|
||||
|
||||
Site configuration:
|
||||
|
||||
@@ -3,16 +3,17 @@ title: Plain
|
||||
description: Returns the rendered content of the given page, removing all HTML tags.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Content
|
||||
- methods/page/Summary
|
||||
- methods/page/ContentWithoutSummary
|
||||
- methods/page/RawContent
|
||||
- methods/page/PlainWords
|
||||
- methods/page/RenderShortcodes
|
||||
returnType: string
|
||||
signatures: [PAGE.Plain]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Content
|
||||
- methods/page/Summary
|
||||
- methods/page/ContentWithoutSummary
|
||||
- methods/page/RawContent
|
||||
- methods/page/PlainWords
|
||||
- methods/page/RenderShortcodes
|
||||
returnType: string
|
||||
signatures: [PAGE.Plain]
|
||||
---
|
||||
|
||||
The `Plain` method on a `Page` object renders Markdown and [shortcodes](g) to HTML, then strips the HTML [tags]. It does not strip HTML [entities].
|
||||
|
||||
@@ -3,16 +3,17 @@ title: PlainWords
|
||||
description: Calls the Plain method, splits the result into a slice of words, and returns the slice.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Content
|
||||
- methods/page/Summary
|
||||
- methods/page/ContentWithoutSummary
|
||||
- methods/page/RawContent
|
||||
- methods/page/Plain
|
||||
- methods/page/RenderShortcodes
|
||||
returnType: '[]string'
|
||||
signatures: [PAGE.PlainWords]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Content
|
||||
- methods/page/Summary
|
||||
- methods/page/ContentWithoutSummary
|
||||
- methods/page/RawContent
|
||||
- methods/page/Plain
|
||||
- methods/page/RenderShortcodes
|
||||
returnType: '[]string'
|
||||
signatures: [PAGE.PlainWords]
|
||||
---
|
||||
|
||||
The `PlainWords` method on a `Page` object calls the [`Plain`] method, then uses Go's [`strings.Fields`] function to split the result into words.
|
||||
|
||||
@@ -3,15 +3,16 @@ title: Prev
|
||||
description: Returns the previous page in a site's collection of regular pages, relative to the current page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Next
|
||||
- methods/page/NextInSection
|
||||
- methods/page/PrevInSection
|
||||
- methods/pages/Next
|
||||
- methods/pages/Prev
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.Prev]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Next
|
||||
- methods/page/NextInSection
|
||||
- methods/page/PrevInSection
|
||||
- methods/pages/Next
|
||||
- methods/pages/Prev
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.Prev]
|
||||
---
|
||||
|
||||
{{% include "methods/page/_common/next-and-prev.md" %}}
|
||||
{{% include "/_common/methods/page/next-and-prev.md" %}}
|
||||
@@ -1,15 +1,16 @@
|
||||
---
|
||||
title: PrevInSection
|
||||
description: Returns the previous regular page in a section, relative to the given page.
|
||||
description: Returns the previous regular page in a section, relative to the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/NextInSection
|
||||
- methods/pages/Next
|
||||
- methods/pages/Prev
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.PrevInSection]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/NextInSection
|
||||
- methods/pages/Next
|
||||
- methods/pages/Prev
|
||||
returnType: page.Page
|
||||
signatures: [PAGE.PrevInSection]
|
||||
---
|
||||
|
||||
{{% include "methods/page/_common/nextinsection-and-previnsection.md" %}}
|
||||
{{% include "/_common/methods/page/nextinsection-and-previnsection.md" %}}
|
||||
@@ -3,13 +3,14 @@ title: PublishDate
|
||||
description: Returns the publish date of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Date
|
||||
- methods/page/ExpiryDate
|
||||
- methods/page/LastMod
|
||||
returnType: time.Time
|
||||
signatures: [PAGE.PublishDate]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Date
|
||||
- methods/page/ExpiryDate
|
||||
- methods/page/LastMod
|
||||
returnType: time.Time
|
||||
signatures: [PAGE.PublishDate]
|
||||
---
|
||||
|
||||
By default, Hugo excludes pages with future publish dates when building your site. To include future pages, use the `--buildFuture` command line flag.
|
||||
@@ -30,6 +31,6 @@ The publish date is a [time.Time] value. Format and localize the value with the
|
||||
In the example above we explicitly set the publish date in front matter. With Hugo's default configuration, the `PublishDate` method returns the front matter value. This behavior is configurable, allowing you to set fallback values if the publish date is not defined in front matter. See [details].
|
||||
|
||||
[`time.Format`]: /functions/time/format/
|
||||
[details]: /getting-started/configuration/#configure-dates
|
||||
[details]: /configuration/front-matter/#dates
|
||||
[time methods]: /methods/time/
|
||||
[time.Time]: https://pkg.go.dev/time#Time
|
||||
@@ -3,16 +3,17 @@ title: RawContent
|
||||
description: Returns the raw content of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Content
|
||||
- methods/page/Summary
|
||||
- methods/page/ContentWithoutSummary
|
||||
- methods/page/Plain
|
||||
- methods/page/PlainWords
|
||||
- methods/page/RenderShortcodes
|
||||
returnType: string
|
||||
signatures: [PAGE.RawContent]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Content
|
||||
- methods/page/Summary
|
||||
- methods/page/ContentWithoutSummary
|
||||
- methods/page/Plain
|
||||
- methods/page/PlainWords
|
||||
- methods/page/RenderShortcodes
|
||||
returnType: string
|
||||
signatures: [PAGE.RawContent]
|
||||
---
|
||||
|
||||
The `RawContent` method on a `Page` object returns the raw content. The raw content does not include front matter.
|
||||
@@ -21,12 +22,10 @@ The `RawContent` method on a `Page` object returns the raw content. The raw cont
|
||||
{{ .RawContent }}
|
||||
```
|
||||
|
||||
This is useful when rendering a page in a plain text [output format].
|
||||
This is useful when rendering a page in a plain text [output format](g).
|
||||
|
||||
{{< note >}}
|
||||
[Shortcodes](g) within the content are not rendered. To get the raw content with shortcodes rendered, use the [`RenderShortcodes`] method on a `Page` object.
|
||||
|
||||
[`RenderShortcodes`]: /methods/page/rendershortcodes/
|
||||
{{< /note >}}
|
||||
|
||||
[output format]: /templates/output-formats/
|
||||
@@ -3,12 +3,13 @@ title: ReadingTime
|
||||
description: Returns the estimated reading time, in minutes, for the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/WordCount
|
||||
- methods/page/FuzzyWordCount
|
||||
returnType: int
|
||||
signatures: [PAGE.ReadingTime]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/WordCount
|
||||
- methods/page/FuzzyWordCount
|
||||
returnType: int
|
||||
signatures: [PAGE.ReadingTime]
|
||||
---
|
||||
|
||||
The estimated reading time is calculated by dividing the number of words in the content by the reading speed.
|
||||
|
||||
@@ -3,27 +3,27 @@ title: Ref
|
||||
description: Returns the absolute URL of the page with the given path, language, and output format.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/RelRef
|
||||
- functions/urls/RelRef
|
||||
- functions/urls/Ref
|
||||
returnType: string
|
||||
signatures: [PAGE.Ref OPTIONS]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/RelRef
|
||||
- functions/urls/RelRef
|
||||
- functions/urls/Ref
|
||||
returnType: string
|
||||
signatures: [PAGE.Ref OPTIONS]
|
||||
---
|
||||
|
||||
The map of option contains:
|
||||
## Usage
|
||||
|
||||
path
|
||||
: (`string`) The path to the page, relative to the `content` directory. Required.
|
||||
The `Ref` method accepts a single argument: an options map.
|
||||
|
||||
lang
|
||||
: (`string`) The language (site) to search for the page. Default is the current language. Optional.
|
||||
## Options
|
||||
|
||||
outputFormat
|
||||
: (`string`) The output format to search for the page. Default is the current output format. Optional.
|
||||
{{% include "_common/ref-and-relref-options.md" %}}
|
||||
|
||||
The examples below show the rendered output when visiting a page on the English language version of the site:
|
||||
## Examples
|
||||
|
||||
The following examples show the rendered output for a page on the English version of the site:
|
||||
|
||||
```go-html-template
|
||||
{{ $opts := dict "path" "/books/book-1" }}
|
||||
@@ -36,9 +36,6 @@ The examples below show the rendered output when visiting a page on the English
|
||||
{{ .Ref $opts }} → https://example.org/de/books/book-1/index.json
|
||||
```
|
||||
|
||||
By default, Hugo will throw an error and fail the build if it cannot resolve the path. You can change this to a warning in your site configuration, and specify a URL to return when the path cannot be resolved.
|
||||
## Error handling
|
||||
|
||||
{{< code-toggle file=hugo >}}
|
||||
refLinksErrorLevel = 'warning'
|
||||
refLinksNotFoundURL = '/some/other/url'
|
||||
{{< /code-toggle >}}
|
||||
{{% include "_common/ref-and-relref-error-handling.md" %}}
|
||||
@@ -3,15 +3,16 @@ title: RegularPages
|
||||
description: Returns a collection of regular pages within the current section.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Pages
|
||||
- methods/page/RegularPagesRecursive
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.RegularPages]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Pages
|
||||
- methods/page/RegularPagesRecursive
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.RegularPages]
|
||||
---
|
||||
|
||||
The `RegularPages` method on a `Page` object is available to these [page kinds](g): `home`, `section`, `taxonomy`, and `term`. The templates for these page kinds receive a page [collection](g) in [context](g).
|
||||
The `RegularPages` method on a `Page` object is available to these [page kinds](g): `home`, `section`, `taxonomy`, and `term`. The templates for these page kinds receive a page [collection](g) in [context](g), in the [default sort order](g).
|
||||
|
||||
Range through the page collection in your template:
|
||||
|
||||
|
||||
@@ -3,15 +3,16 @@ title: RegularPagesRecursive
|
||||
description: Returns a collection of regular pages within the current section, and regular pages within all descendant sections.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Pages
|
||||
- methods/page/RegularPages
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.RegularPagesRecursive]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Pages
|
||||
- methods/page/RegularPages
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.RegularPagesRecursive]
|
||||
---
|
||||
|
||||
The `RegularPagesRecursive` method on a `Page` object is available to these [page kinds](g): `home`, `section`, `taxonomy`, and `term`. The templates for these page kinds receive a page [collection](g) in [context](g).
|
||||
The `RegularPagesRecursive` method on a `Page` object is available to these [page kinds](g): `home`, `section`, `taxonomy`, and `term`. The templates for these page kinds receive a page [collection](g) in [context](g), in the [default sort order](g).
|
||||
|
||||
Range through the page collection in your template:
|
||||
|
||||
|
||||
@@ -3,11 +3,12 @@ title: RelPermalink
|
||||
description: Returns the relative permalink of the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Permalink
|
||||
returnType: string
|
||||
signatures: [PAGE.RelPermalink]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Permalink
|
||||
returnType: string
|
||||
signatures: [PAGE.RelPermalink]
|
||||
---
|
||||
|
||||
Site configuration:
|
||||
|
||||
@@ -3,27 +3,27 @@ title: RelRef
|
||||
description: Returns the relative URL of the page with the given path, language, and output format.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Ref
|
||||
- functions/urls/Ref
|
||||
- functions/urls/RelRef
|
||||
returnType: string
|
||||
signatures: [PAGE.RelRef OPTIONS]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- methods/page/Ref
|
||||
- functions/urls/Ref
|
||||
- functions/urls/RelRef
|
||||
returnType: string
|
||||
signatures: [PAGE.RelRef OPTIONS]
|
||||
---
|
||||
|
||||
The map of option contains:
|
||||
## Usage
|
||||
|
||||
path
|
||||
: (`string`) The path to the page, relative to the `content` directory. Required.
|
||||
The `RelRef` method accepts a single argument: an options map.
|
||||
|
||||
lang
|
||||
: (`string`) The language (site) to search for the page. Default is the current language. Optional.
|
||||
## Options
|
||||
|
||||
outputFormat
|
||||
: (`string`) The output format to search for the page. Default is the current output format. Optional.
|
||||
{{% include "_common/ref-and-relref-options.md" %}}
|
||||
|
||||
The examples below show the rendered output when visiting a page on the English language version of the site:
|
||||
## Examples
|
||||
|
||||
The following examples show the rendered output for a page on the English version of the site:
|
||||
|
||||
```go-html-template
|
||||
{{ $opts := dict "path" "/books/book-1" }}
|
||||
@@ -36,9 +36,6 @@ The examples below show the rendered output when visiting a page on the English
|
||||
{{ .RelRef $opts }} → /de/books/book-1/index.json
|
||||
```
|
||||
|
||||
By default, Hugo will throw an error and fail the build if it cannot resolve the path. You can change this to a warning in your site configuration, and specify a URL to return when the path cannot be resolved.
|
||||
## Error handling
|
||||
|
||||
{{< code-toggle file=hugo >}}
|
||||
refLinksErrorLevel = 'warning'
|
||||
refLinksNotFoundURL = '/some/other/url'
|
||||
{{< /code-toggle >}}
|
||||
{{% include "_common/ref-and-relref-error-handling.md" %}}
|
||||
@@ -3,12 +3,13 @@ title: Render
|
||||
description: Renders the given template with the given page as context.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/partials/Include
|
||||
- functions/partials/IncludeCached
|
||||
returnType: template.HTML
|
||||
signatures: [PAGE.Render NAME]
|
||||
params:
|
||||
functions_and_methods:
|
||||
related:
|
||||
- functions/partials/Include
|
||||
- functions/partials/IncludeCached
|
||||
returnType: template.HTML
|
||||
signatures: [PAGE.Render NAME]
|
||||
aliases: [/functions/render]
|
||||
---
|
||||
|
||||
|
||||
Loaded 100 of 911 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user