From 1a3ca9010df510caef29f66772314707dd3f6110 Mon Sep 17 00:00:00 2001 From: Manuel Reithuber Date: Sun, 19 Nov 2017 13:32:31 +0100 Subject: [PATCH 1/3] layouts/partial/menu.html: using the 'linkTitle' attribute as link text (if present) --- layouts/partials/menu.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html index 9780b83271..0a157f1812 100644 --- a/layouts/partials/menu.html +++ b/layouts/partials/menu.html @@ -103,7 +103,7 @@ {{if .Params.alwaysopen}}parent{{end}} "> - {{safeHTML .Params.Pre}}{{.Title}}{{safeHTML .Params.Post}} + {{safeHTML .Params.Pre}}{{or .LinkTitle .Title}}{{safeHTML .Params.Post}} {{ if $showvisitedlinks}} {{ end }} @@ -139,7 +139,7 @@ {{ if not .Params.Hidden }}
  • - {{safeHTML .Params.Pre}}{{.Title}}{{safeHTML .Params.Post}} + {{safeHTML .Params.Pre}}{{or .LinkTitle .Title}}{{safeHTML .Params.Post}} {{ if $showvisitedlinks}}{{end}}
  • From d335f88af43614ba4fd092052867272e46186fb2 Mon Sep 17 00:00:00 2001 From: Manuel Reithuber Date: Sun, 19 Nov 2017 13:55:30 +0100 Subject: [PATCH 2/3] menu.html: added support for a 'menuTitle' frontmatter parameter --- layouts/partials/menu.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html index 0a157f1812..ed436c57e3 100644 --- a/layouts/partials/menu.html +++ b/layouts/partials/menu.html @@ -103,7 +103,7 @@ {{if .Params.alwaysopen}}parent{{end}} "> - {{safeHTML .Params.Pre}}{{or .LinkTitle .Title}}{{safeHTML .Params.Post}} + {{safeHTML .Params.Pre}}{{or .Params.menuTitle .LinkTitle .Title}}{{safeHTML .Params.Post}} {{ if $showvisitedlinks}} {{ end }} @@ -139,7 +139,7 @@ {{ if not .Params.Hidden }}
  • - {{safeHTML .Params.Pre}}{{or .LinkTitle .Title}}{{safeHTML .Params.Post}} + {{safeHTML .Params.Pre}}{{or .Params.menuTitle .LinkTitle .Title}}{{safeHTML .Params.Post}} {{ if $showvisitedlinks}}{{end}}
  • From 4a8d501baf2c6ed39e81336967525b79cf7e07e3 Mon Sep 17 00:00:00 2001 From: Manuel Reithuber Date: Sun, 19 Nov 2017 14:48:37 +0100 Subject: [PATCH 3/3] added documentation for the `menuTitle` attribute --- exampleSite/content/cont/pages/_index.en.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/exampleSite/content/cont/pages/_index.en.md b/exampleSite/content/cont/pages/_index.en.md index e12e6fba45..e2ff25d324 100644 --- a/exampleSite/content/cont/pages/_index.en.md +++ b/exampleSite/content/cont/pages/_index.en.md @@ -98,6 +98,8 @@ Each Hugo page has to define a [Front Matter](https://gohugo.io/content/front-ma # Table of content (toc) is enabled by default. Set this parameter to true to disable it. # Note: Toc is always disabled for chapter pages disableToc = "false" +# If set, this will be used for the page's menu entry (instead of the `title` attribute) +menuTitle = "" # The title of the page in menu will be prefixed by this HTML content pre = "" # The title of the page in menu will be postfixed by this HTML content @@ -139,6 +141,22 @@ weight = 5 +++ ``` +### Using a custom title for menu entries + +By default, **Hugo-theme-learn** will use a page's `title` attribute for the menu item (or `linkTitle` if defined). + +But a page's title has to be descriptive on its own while the menu is a hierarchy. +We've added the `menuTitle` parameter for that purpose: + +For example (for a page named `content/install/linux.md`): + +```toml ++++ +title = "Install on Linux" +menuTitle = "Linux" ++++ +``` + ## Homepage To configure your home page, you basically have three choices: