mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
---
|
||||
title: Global functions
|
||||
linkTitle: global
|
||||
description: Global template functions to access page and site data.
|
||||
description: Use these global functions to access page and site data.
|
||||
categories: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
---
|
||||
|
||||
Use these global functions to access page and site data.
|
||||
|
@@ -3,13 +3,11 @@ title: page
|
||||
description: Provides global access to a Page object.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/global/site
|
||||
returnType:
|
||||
signatures: [page]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType:
|
||||
signatures: [page]
|
||||
aliases: [/functions/page]
|
||||
---
|
||||
|
||||
@@ -27,13 +25,12 @@ When a `Page` object is not in context, you can use the global `page` function:
|
||||
{{ page.Params.foo }}
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
Do not use the global `page` function in shortcodes, partials called by shortcodes, or cached partials. See [warnings](#warnings) below.
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> Do not use the global `page` function in shortcodes, partials called by shortcodes, or cached partials. See [warnings](#warnings) below.
|
||||
|
||||
## Explanation
|
||||
|
||||
Hugo almost always passes a `Page` as the data context into the top level template (e.g., `single.html`). The one exception is the multihost sitemap template. This means that you can access the current page with the `.` in the template.
|
||||
Hugo almost always passes a `Page` as the data context into the top-level template (e.g., `single.html`). The one exception is the multihost sitemap template. This means that you can access the current page with the `.` in the template.
|
||||
|
||||
But when you are deeply nested inside of a [content view](g), [partial](g), or [render hook](g), it is not always practical or possible to access the `Page` object.
|
||||
|
||||
@@ -99,5 +96,5 @@ When you call the [`Summary`] method, Hugo renders the page content including sh
|
||||
|
||||
If Hugo renders the section page before a content page, the cached rendered shortcode will be incorrect. You cannot control the rendering sequence due to concurrency.
|
||||
|
||||
[`Summary`]: /methods/page/summary/
|
||||
[`partialCached`]: /functions/partials/includecached/
|
||||
[`Summary`]: /methods/page/summary/
|
||||
|
@@ -3,12 +3,11 @@ title: site
|
||||
description: Provides global access to the current Site object.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/global/page
|
||||
returnType:
|
||||
signatures: [site]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType:
|
||||
signatures: [site]
|
||||
aliases: [/functions/site]
|
||||
---
|
||||
|
||||
@@ -27,6 +26,5 @@ When the `Site` object is in context you can use the `Site` property:
|
||||
{{ $.Site.Params.foo }}
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
To simplify your templates, use the global `site` function regardless of whether the `Site` object is in context.
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> To simplify your templates, use the global `site` function regardless of whether the `Site` object is in context.
|
||||
|
Reference in New Issue
Block a user