diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2025-04-10 13:04:51 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2025-04-10 13:04:51 +0200 |
commit | 653f1c1d462332bccf303a5040e5cd99c89a4378 (patch) | |
tree | c993984f169a240567526e9993261241c0cda771 /docs/content/en/methods/page/Path.md | |
parent | 208a0de6c31354df6f9463d49e90db9dec935169 (diff) | |
parent | 5be51ac3db225d5df501ed1fa1499c41d97dbf65 (diff) | |
download | hugo-653f1c1d462332bccf303a5040e5cd99c89a4378.tar.gz hugo-653f1c1d462332bccf303a5040e5cd99c89a4378.zip |
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
Diffstat (limited to 'docs/content/en/methods/page/Path.md')
-rw-r--r-- | docs/content/en/methods/page/Path.md | 78 |
1 files changed, 32 insertions, 46 deletions
diff --git a/docs/content/en/methods/page/Path.md b/docs/content/en/methods/page/Path.md index 83ad01b94..db4e7d629 100644 --- a/docs/content/en/methods/page/Path.md +++ b/docs/content/en/methods/page/Path.md @@ -3,40 +3,26 @@ 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: + 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. - -The meaning of, and value returned by, the `Path` method on a `Page` object changed with the release of [v0.123.0] in February 2024. - -[v0.92.0]: https://github.com/gohugoio/hugo/releases/tag/v0.92.0 -[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 +> [!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. +> +> The meaning of, and value returned by, the `Path` method on a `Page` object changed with the release of [v0.123.0] in February 2024. 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. @@ -101,25 +87,13 @@ Methods|Functions|Shortcodes :--|:--|:-- [`Site.GetPage`]|[`urls.Ref`]|[`ref`] [`Page.GetPage`]|[`urls.RelRef`]|[`relref`] -[`Page.Ref`]|| -[`Page.RelRef`]|| -[`Shortcode.Ref`]|| -[`Shortcode.RelRef`]|| - -[`urls.Ref`]: /functions/urls/ref/ -[`urls.RelRef`]: /functions/urls/relref/ -[`Page.GetPage`]: /methods/page/getpage/ -[`Site.GetPage`]: /methods/site/getpage/ -[`ref`]: /shortcodes/ref/ -[`relref`]: /shortcodes/relref/ -[`Page.Ref`]: /methods/page/ref/ -[`Page.RelRef`]: /methods/page/relref/ -[`Shortcode.Ref`]: /methods/shortcode/ref -[`Shortcode.RelRef`]: /methods/shortcode/relref +[`Page.Ref`]||| +[`Page.RelRef`]||| +[`Shortcode.Ref`]||| +[`Shortcode.RelRef`]||| -{{% note %}} -Specify the logical path when using any of these methods, functions, or shortcodes. If you include a file extension or language identifier, Hugo will strip these values before finding the page in the logical tree. -{{% /note %}} +> [!note] +> Specify the logical path when using any of these methods, functions, or shortcodes. If you include a file extension or language identifier, Hugo will strip these values before finding the page in the logical tree. ## Logical tree @@ -149,6 +123,18 @@ A key difference between these trees is the relative path from p1 to p2: - In the file tree, the relative path from p1 to p2 is `../p2.md` - In the logical tree, the relative path is `p2` -{{% note %}} -Remember to use the logical path when using any of the methods, functions, or shortcodes listed in the previous section. If you include a file extension or language identifier, Hugo will strip these values before finding the page in the logical tree. -{{% /note %}} +> [!note] +> Remember to use the logical path when using any of the methods, functions, or shortcodes listed in the previous section. If you include a file extension or language identifier, Hugo will strip these values before finding the page in the logical tree. + +[`Page.GetPage`]: /methods/page/getpage/ +[`Page.Ref`]: /methods/page/ref/ +[`Page.RelRef`]: /methods/page/relref/ +[`ref`]: /shortcodes/ref/ +[`relref`]: /shortcodes/relref/ +[`Shortcode.Ref`]: /methods/shortcode/ref +[`Shortcode.RelRef`]: /methods/shortcode/relref +[`Site.GetPage`]: /methods/site/getpage/ +[`urls.Ref`]: /functions/urls/ref/ +[`urls.RelRef`]: /functions/urls/relref/ +[v0.123.0]: https://github.com/gohugoio/hugo/releases/tag/v0.123.0 +[v0.92.0]: https://github.com/gohugoio/hugo/releases/tag/v0.92.0 |