From 49b2f8f770804e95af85e2dfdb515518b4f46821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Mon, 30 Dec 2024 20:04:38 +0100 Subject: [PATCH] docs: example for cascading sidebar menu reusing existing menus #970 --- .../configuration/sidebar/menus/_index.en.md | 22 ++++++++++++++----- layouts/partials/version.txt | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/exampleSite/content/configuration/sidebar/menus/_index.en.md b/exampleSite/content/configuration/sidebar/menus/_index.en.md index 03b216b506..30032f8fc5 100644 --- a/exampleSite/content/configuration/sidebar/menus/_index.en.md +++ b/exampleSite/content/configuration/sidebar/menus/_index.en.md @@ -9,12 +9,16 @@ weight = 4 The theme can build menu trees from [the structure of your page files](authoring/structure) or from [Hugo's build in menu feature](https://gohugo.io/content-management/menus/). -- {{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} All configuration options in your `hugo.toml` apply to all menus but can be changed individually. +--- + +- {{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} Configuration options in your `hugo.toml` apply to all menus. - {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} In case of page structure menus, individual configuration is done via a page's front matter. - {{% badge color="blueviolet" icon="bars" title=" " %}}Menu{{% /badge %}}. In case of Hugo menus, individual configuration is done via a menu entry's configuration. +--- + ## Expand State of Submenus {{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} You can change how submenus appear with `alwaysopen`. @@ -222,7 +226,9 @@ sidebarmenus = [ Suppose you are building a site that contains a topmost `blog` and `documentation` section. -When the user is on one of the blog pages he should only see a menu containing all blog pages, while on a documentation page he should only see a menu containing all doc pages. +When the user is on one of the blog pages he should only see a page menu containing all blog pages, while on a documentation page he should only see a page menu containing all doc pages. + +For both sections, the default `shortcuts` Hugo menu should be displayed as if [defaults menus](#defining-sidebar-menus) were used. Directory structure: @@ -232,23 +238,26 @@ content │ ├── post-1.md │ ├── post-2.md │ ├── post-3.md -│ └── _index_.md +│ └── _index.md ├── docs │ ├── topic-1.md │ ├── topic-2.md │ ├── topic-3.md -│ └── _index_.md +│ └── _index.md └── _index.md ```` {{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} Using [Hugo's cascade feature](https://gohugo.io/content-management/front-matter/#cascade), we can redefine the menus once in `blog/_index.md` and `docs/_index.md` setting `sidebarmenus` so they will be used in all children pages. +Setting the `sidebarmenus` Front Matter will overwrite all default menus. If you want to display the `shortcuts` Hugo menu as well like in this example, you have to declare it with the Front Matter as given in the [default options](#defining-sidebar-menus). + {{< multiconfig fm=true file="blog/_index.md">}} title = 'Blog' [[cascade]] [cascade.params] sidebarmenus = [ { type = 'page', identifier = 'blog', pageRef = '/blog' }, + { type = 'menu', identifier = 'shortcuts' }, ] {{< /multiconfig >}} @@ -258,6 +267,7 @@ title = 'Documentation' [cascade.params] sidebarmenus = [ { type = 'page', identifier = 'docs', pageRef = '/docs' }, + { type = 'menu', identifier = 'shortcuts' }, ] {{< /multiconfig >}} @@ -273,11 +283,11 @@ content │ ├── ref-a.md │ ├── ref-b.md │ ├── ref-c.md -│ └── _index_.md +│ └── _index.md ├── topic-blue.md ├── topic-red.md ├── topic-yellow.md -└── _index_.md +└── _index.md ```` You now want to include `ref-b` as separate `topic-green` entry after `topic-blue` in your menu. diff --git a/layouts/partials/version.txt b/layouts/partials/version.txt index 7c5c74a55a..d700eb38a4 100644 --- a/layouts/partials/version.txt +++ b/layouts/partials/version.txt @@ -1 +1 @@ -7.2.1+ec88e24f46955bcf1aa3f38ac143982eff08d8a6 \ No newline at end of file +7.2.1+d25f856477223170b0de0b284252aa54b3e6255b \ No newline at end of file