hugo-theme-relearn/exampleSite/content/configuration/menushortcuts.en.md

162 lines
5.3 KiB
Markdown
Raw Normal View History

+++
2024-09-21 11:05:58 +00:00
title = "Menu Shortcuts"
weight = 5
+++
2017-08-20 15:10:29 +00:00
You can define additional menu entries or shortcuts in the navigation menu without any link to content.
## Basic configuration
Edit the website configuration `hugo.toml` and add a `[[menu.shortcuts]]` entry for each link your want to add.
2017-08-20 15:10:29 +00:00
Example from the current website:
2024-03-02 10:04:52 +00:00
{{< multiconfig file=hugo >}}
[[menu.shortcuts]]
name = "<i class='fa-fw fab fa-github'></i> GitHub repo"
identifier = "ds"
url = "https://github.com/McShelby/hugo-theme-relearn"
weight = 10
[[menu.shortcuts]]
name = "<i class='fa-fw fas fa-camera'></i> Showcases"
url = "showcase/"
weight = 11
[[menu.shortcuts]]
name = "<i class='fa-fw fas fa-bookmark'></i> Hugo Documentation"
identifier = "hugodoc"
url = "https://gohugo.io/"
weight = 20
[[menu.shortcuts]]
name = "<i class='fa-fw fas fa-bullhorn'></i> Credits"
url = "more/credits/"
weight = 30
2021-10-24 09:53:09 +00:00
[[menu.shortcuts]]
name = "<i class='fa-fw fas fa-tags'></i> Tags"
url = "tags/"
2021-10-24 09:53:09 +00:00
weight = 40
2024-03-02 10:04:52 +00:00
{{< /multiconfig >}}
2017-08-20 15:10:29 +00:00
By default, shortcuts are preceded by a title. This title can be disabled by setting `disableShortcutsTitle=true`.
2022-10-31 11:10:36 +00:00
However, if you want to keep the title but change its value, it can be overridden by changing your local i18n translation string configuration.
2017-08-20 15:10:29 +00:00
For example, in your local `i18n/en.toml` file, add the following content
2024-03-02 10:04:52 +00:00
````toml {title="en.toml"}
[Shortcuts-Title]
other = "<Your value>"
````
2017-08-20 15:10:29 +00:00
Read more about [hugo menu](https://gohugo.io/extras/menus/) and [hugo i18n translation strings](https://gohugo.io/content-management/multilingual/#translation-of-strings)
## Configuration for Multilingual mode {#i18n}
When using a multilingual website, you can set different menus for each language. In the `hugo.toml` file, prefix your menu configuration by `Languages.<language-id>`.
2017-08-20 15:10:29 +00:00
Example from the current website:
2024-03-02 10:04:52 +00:00
{{< multiconfig file=hugo >}}
[languages]
[languages.en]
title = "Hugo Relearn Theme"
2021-10-24 09:53:09 +00:00
weight = 1
languageName = "English"
[languages.en.params]
landingPageName = "<i class='fa-fw fas fa-home'></i> Home"
2021-10-24 09:53:09 +00:00
[[languages.en.menu.shortcuts]]
name = "<i class='fa-fw fab fa-github'></i> GitHub repo"
2021-10-24 09:53:09 +00:00
identifier = "ds"
url = "https://github.com/McShelby/hugo-theme-relearn"
weight = 10
[[languages.en.menu.shortcuts]]
name = "<i class='fa-fw fas fa-camera'></i> Showcases"
pageRef = "showcase/"
2021-10-24 09:53:09 +00:00
weight = 11
[[languages.en.menu.shortcuts]]
name = "<i class='fa-fw fas fa-bookmark'></i> Hugo Documentation"
2021-10-24 09:53:09 +00:00
identifier = "hugodoc"
url = "https://gohugo.io/"
weight = 20
[[languages.en.menu.shortcuts]]
name = "<i class='fa-fw fas fa-bullhorn'></i> Credits"
pageRef = "more/credits/"
2021-10-24 09:53:09 +00:00
weight = 30
[[languages.en.menu.shortcuts]]
name = "<i class='fa-fw fas fa-tags'></i> Tags"
pageRef = "tags/"
2021-10-24 09:53:09 +00:00
weight = 40
[languages.pir]
title = "Cap'n Hugo Relearrrn Theme"
2021-10-24 09:53:09 +00:00
weight = 1
languageName = "Arrr! Pirrrates"
[languages.pir.params]
landingPageName = "<i class='fa-fw fas fa-home'></i> Arrr! Home"
2021-10-24 09:53:09 +00:00
[[languages.pir.menu.shortcuts]]
name = "<i class='fa-fw fab fa-github'></i> GitHub repo"
2021-10-24 09:53:09 +00:00
identifier = "ds"
url = "https://github.com/McShelby/hugo-theme-relearn"
weight = 10
[[languages.pir.menu.shortcuts]]
name = "<i class='fa-fw fas fa-camera'></i> Showcases"
pageRef = "showcase/"
2021-10-24 09:53:09 +00:00
weight = 11
[[languages.pir.menu.shortcuts]]
name = "<i class='fa-fw fas fa-bookmark'></i> Cap'n Hugo Documentat'n"
2021-10-24 09:53:09 +00:00
identifier = "hugodoc"
url = "https://gohugo.io/"
weight = 20
[[languages.pir.menu.shortcuts]]
name = "<i class='fa-fw fas fa-bullhorn'></i> Crrredits"
pageRef = "more/credits/"
2021-10-24 09:53:09 +00:00
weight = 30
[[languages.pir.menu.shortcuts]]
name = "<i class='fa-fw fas fa-tags'></i> Arrr! Tags"
pageRef = "tags/"
2021-10-24 09:53:09 +00:00
weight = 40
2024-03-02 10:04:52 +00:00
{{< /multiconfig >}}
2017-08-20 15:10:29 +00:00
Read more about [hugo menu](https://gohugo.io/extras/menus/) and [hugo multilingual menus](https://gohugo.io/content-management/multilingual/#menus)
## Shortcuts to pages inside of your project
If you have shortcuts to pages inside of your project and you don't want them to show up in page menu section, you have two choices:
2023-10-24 17:28:03 +00:00
1. Make the page file for the shortcut a [headless branch bundle](https://gohugo.io/content-management/page-bundles/#headless-bundle) (contained in its own subdirectory and called `_index.md`) and add the following frontmatter configuration to the file (see exampleSite's `content/showcase/_index.en.md`). This causes its content to **not** be ontained in the sitemap.
2024-03-02 10:04:52 +00:00
{{< multiconfig fm=true >}}
title = "Showcase"
[_build]
render = "always"
list = "never"
publishResources = true
2024-03-02 10:04:52 +00:00
{{< /multiconfig >}}
2024-03-02 13:19:46 +00:00
2. Store the page file for the shortcut below a parent headless branch bundle and add the following frontmatter to he **parent** (see exampleSite's `content/more/_index.en.md`). **Don't give this page a `title`** as this will cause it to be shown in the breadcrumbs - a thing you most likely don't want.
2024-03-02 10:04:52 +00:00
{{< multiconfig fm=true >}}
[_build]
render = "never"
list = "never"
publishResources = false
2024-03-02 10:04:52 +00:00
{{< /multiconfig >}}
In this case, the file itself can be a branch bundle, leaf bundle or simple page (see exampleSite's `content/more/credits.en.md`). This causes its content to be contained in the sitemap.
2024-03-02 10:04:52 +00:00
{{< multiconfig fm=true >}}
title = "Credits"
2024-03-02 10:04:52 +00:00
{{< /multiconfig >}}