Debian Codegraph @

docs/content/en/methods/page/Page.md

raw
1 ---
2 title: Page
3 description: Returns the Page object of the given page.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: page.Page
9 signatures: [PAGE.Page]
10 ---
11
12 This is a convenience method, useful within _partial_ templates that are called from both _shortcode_ and other template types.
13
14 ```go-html-template {file="layouts/_shortcodes/foo.html"}
15 {{ partial "my-partial.html" . }}
16 ```
17
18 When the _shortcode_ template calls the _partial_ template, it passes the current [context](g) (the dot). The context includes identifiers such as `Page`, `Params`, `Inner`, and `Name`.
19
20 ```go-html-template {file="layouts/page.html"}
21 {{ partial "my-partial.html" . }}
22 ```
23
24 When the _page_ template calls the _partial_ template, it also passes the current context (the dot). But in this case, the dot _is_ the `Page` object.
25
26 ```go-html-template {file="layouts/_partials/my-partial.html"}
27 The page title is: {{ .Page.Title }}
28 ```
29
30 To handle both scenarios, the _partial_ template must be able to access the `Page` object with `Page.Page`.
31
32 > [!NOTE]
33 > And yes, that means you can do `.Page.Page.Page.Page.Title` too.
34 >
35 > But don't.