hugo/docs/content/en/methods/page/Page.md
Bjørn Erik Pedersen 5fd1e74903
Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'
```
git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash
```

Closes #11925
2024-01-27 10:48:57 +01:00

1.2 KiB

title description categories keywords action
Page Returns the Page object of the given page.
related returnType signatures
page.Page
PAGE.Page

This is a convenience method, useful within partial templates that are called from both shortcodes and page templates.

{{< code file=layouts/shortcodes/foo.html >}} {{ partial "my-partial.html" . }} {{< /code >}}

When the shortcode calls the partial, it passes the current context (the dot). The context includes identifiers such as Page, Params, Inner, and Name.

{{< 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 >}} The page title is: {{ .Page.Title }} {{< /code >}}

To handle both scenarios, the partial template must be able to access the Page object with Page.Page.

{{% note %}} And yes, that means you can do .Page.Page.Page.Page.Title too.

But don't. {{% /note %}}