aboutsummaryrefslogtreecommitdiff
path: root/layouts/partials/docs
diff options
context:
space:
mode:
authorMikey Lombardi (He/Him) <mlombardi@microsoft.com>2022-10-05 03:01:03 -0500
committerGitHub <noreply@github.com>2022-10-05 10:01:03 +0200
commit6090fddebdf7272995c9cef36edf0cff61e261b9 (patch)
tree4ae6def10dfe18c1f09cb3888358403c3de73ec1 /layouts/partials/docs
parent317ccae23b73f5e49d7341ad57227bd64a89ab38 (diff)
(MAINT) Respect LinkTitle in page metadata (#483)
Prior to this commit, the partial for determining a page title used the `Title` property of a page, if present, or humanized and titleized the file name if not. It did not use the `LinkTitle` property at all (defined in the [front matter][01]). According to the [menu documentation][02]: > The following order is used to determine an Identifier: > > `.Name > .LinkTitle > .Title` > > This means that `.Title` will be used unless `.LinkTitle is present, > etc. Similar, the documentation for [menu entry variables][03] states: > The `name` key, if set for the menu entry, sets this value. If that > key is not set, and if the menu entry is set in a page front-matter, > this value defaults to the page's `.LinkTitle`. Together, these imply that if `.LinkTitle` is specified, it should be preferred over `.Title` for the generated nav menu. [01]: https://gohugo.io/content-management/front-matter/ [02]: https://gohugo.io/content-management/menus/#nesting [03]: https://gohugo.io/variables/menus/#menu-entry-variables
Diffstat (limited to 'layouts/partials/docs')
-rw-r--r--layouts/partials/docs/title.html4
1 files changed, 3 insertions, 1 deletions
diff --git a/layouts/partials/docs/title.html b/layouts/partials/docs/title.html
index a37ac7a..83df5b6 100644
--- a/layouts/partials/docs/title.html
+++ b/layouts/partials/docs/title.html
@@ -4,7 +4,9 @@
-->
{{ $title := "" }}
-{{ if .Title }}
+{{ if .LinkTitle }}
+ {{ $title = .LinkTitle }}
+{{ else if .Title }}
{{ $title = .Title }}
{{ else if and .IsSection .File }}
{{ $title = path.Base .File.Dir | humanize | title }}