Menu extra shortcuts
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.
Example from the current website:
[menu]
[[menu.shortcuts]]
identifier = 'ds'
name = "<i class='fa-fw fab fa-github'></i> GitHub repo"
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]]
identifier = 'hugodoc'
name = "<i class='fa-fw fas fa-bookmark'></i> Hugo Documentation"
url = 'https://gohugo.io/'
weight = 20
[[menu.shortcuts]]
name = "<i class='fa-fw fas fa-bullhorn'></i> Credits"
url = 'more/credits/'
weight = 30
[[menu.shortcuts]]
name = "<i class='fa-fw fas fa-tags'></i> Tags"
url = 'tags/'
weight = 40
menu:
shortcuts:
- identifier: ds
name: <i class='fa-fw fab fa-github'></i> GitHub repo
url: https://github.com/McShelby/hugo-theme-relearn
weight: 10
- name: <i class='fa-fw fas fa-camera'></i> Showcases
url: showcase/
weight: 11
- identifier: hugodoc
name: <i class='fa-fw fas fa-bookmark'></i> Hugo Documentation
url: https://gohugo.io/
weight: 20
- name: <i class='fa-fw fas fa-bullhorn'></i> Credits
url: more/credits/
weight: 30
- name: <i class='fa-fw fas fa-tags'></i> Tags
url: tags/
weight: 40
{
"menu": {
"shortcuts": [
{
"identifier": "ds",
"name": "\u003ci class='fa-fw fab fa-github'\u003e\u003c/i\u003e GitHub repo",
"url": "https://github.com/McShelby/hugo-theme-relearn",
"weight": 10
},
{
"name": "\u003ci class='fa-fw fas fa-camera'\u003e\u003c/i\u003e Showcases",
"url": "showcase/",
"weight": 11
},
{
"identifier": "hugodoc",
"name": "\u003ci class='fa-fw fas fa-bookmark'\u003e\u003c/i\u003e Hugo Documentation",
"url": "https://gohugo.io/",
"weight": 20
},
{
"name": "\u003ci class='fa-fw fas fa-bullhorn'\u003e\u003c/i\u003e Credits",
"url": "more/credits/",
"weight": 30
},
{
"name": "\u003ci class='fa-fw fas fa-tags'\u003e\u003c/i\u003e Tags",
"url": "tags/",
"weight": 40
}
]
}
}
By default, shortcuts are preceded by a title. This title can be disabled by setting disableShortcutsTitle=true
.
However, if you want to keep the title but change its value, it can be overridden by changing your local i18n translation string configuration.
For example, in your local i18n/en.toml
file, add the following content
[Shortcuts-Title]
other = "<Your value>"
Read more about hugo menu and hugo i18n translation strings
Configuration for Multilingual mode
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>
.
Example from the current website:
[languages]
[languages.en]
languageName = 'English'
title = 'Hugo Relearn Theme'
weight = 1
[languages.en.menu]
[[languages.en.menu.shortcuts]]
identifier = 'ds'
name = "<i class='fa-fw fab fa-github'></i> GitHub repo"
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/'
weight = 11
[[languages.en.menu.shortcuts]]
identifier = 'hugodoc'
name = "<i class='fa-fw fas fa-bookmark'></i> Hugo Documentation"
url = 'https://gohugo.io/'
weight = 20
[[languages.en.menu.shortcuts]]
name = "<i class='fa-fw fas fa-bullhorn'></i> Credits"
pageRef = 'more/credits/'
weight = 30
[[languages.en.menu.shortcuts]]
name = "<i class='fa-fw fas fa-tags'></i> Tags"
pageRef = 'tags/'
weight = 40
[languages.en.params]
landingPageName = "<i class='fa-fw fas fa-home'></i> Home"
[languages.pir]
languageName = 'Arrr! Pirrrates'
title = "Cap'n Hugo Relearrrn Theme"
weight = 1
[languages.pir.menu]
[[languages.pir.menu.shortcuts]]
identifier = 'ds'
name = "<i class='fa-fw fab fa-github'></i> GitHub repo"
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/'
weight = 11
[[languages.pir.menu.shortcuts]]
identifier = 'hugodoc'
name = "<i class='fa-fw fas fa-bookmark'></i> Cap'n Hugo Documentat'n"
url = 'https://gohugo.io/'
weight = 20
[[languages.pir.menu.shortcuts]]
name = "<i class='fa-fw fas fa-bullhorn'></i> Crrredits"
pageRef = 'more/credits/'
weight = 30
[[languages.pir.menu.shortcuts]]
name = "<i class='fa-fw fas fa-tags'></i> Arrr! Tags"
pageRef = 'tags/'
weight = 40
[languages.pir.params]
landingPageName = "<i class='fa-fw fas fa-home'></i> Arrr! Home"
languages:
en:
languageName: English
menu:
shortcuts:
- identifier: ds
name: <i class='fa-fw fab fa-github'></i> GitHub repo
url: https://github.com/McShelby/hugo-theme-relearn
weight: 10
- name: <i class='fa-fw fas fa-camera'></i> Showcases
pageRef: showcase/
weight: 11
- identifier: hugodoc
name: <i class='fa-fw fas fa-bookmark'></i> Hugo Documentation
url: https://gohugo.io/
weight: 20
- name: <i class='fa-fw fas fa-bullhorn'></i> Credits
pageRef: more/credits/
weight: 30
- name: <i class='fa-fw fas fa-tags'></i> Tags
pageRef: tags/
weight: 40
params:
landingPageName: <i class='fa-fw fas fa-home'></i> Home
title: Hugo Relearn Theme
weight: 1
pir:
languageName: Arrr! Pirrrates
menu:
shortcuts:
- identifier: ds
name: <i class='fa-fw fab fa-github'></i> GitHub repo
url: https://github.com/McShelby/hugo-theme-relearn
weight: 10
- name: <i class='fa-fw fas fa-camera'></i> Showcases
pageRef: showcase/
weight: 11
- identifier: hugodoc
name: <i class='fa-fw fas fa-bookmark'></i> Cap'n Hugo Documentat'n
url: https://gohugo.io/
weight: 20
- name: <i class='fa-fw fas fa-bullhorn'></i> Crrredits
pageRef: more/credits/
weight: 30
- name: <i class='fa-fw fas fa-tags'></i> Arrr! Tags
pageRef: tags/
weight: 40
params:
landingPageName: <i class='fa-fw fas fa-home'></i> Arrr! Home
title: Cap'n Hugo Relearrrn Theme
weight: 1
{
"languages": {
"en": {
"languageName": "English",
"menu": {
"shortcuts": [
{
"identifier": "ds",
"name": "\u003ci class='fa-fw fab fa-github'\u003e\u003c/i\u003e GitHub repo",
"url": "https://github.com/McShelby/hugo-theme-relearn",
"weight": 10
},
{
"name": "\u003ci class='fa-fw fas fa-camera'\u003e\u003c/i\u003e Showcases",
"pageRef": "showcase/",
"weight": 11
},
{
"identifier": "hugodoc",
"name": "\u003ci class='fa-fw fas fa-bookmark'\u003e\u003c/i\u003e Hugo Documentation",
"url": "https://gohugo.io/",
"weight": 20
},
{
"name": "\u003ci class='fa-fw fas fa-bullhorn'\u003e\u003c/i\u003e Credits",
"pageRef": "more/credits/",
"weight": 30
},
{
"name": "\u003ci class='fa-fw fas fa-tags'\u003e\u003c/i\u003e Tags",
"pageRef": "tags/",
"weight": 40
}
]
},
"params": {
"landingPageName": "\u003ci class='fa-fw fas fa-home'\u003e\u003c/i\u003e Home"
},
"title": "Hugo Relearn Theme",
"weight": 1
},
"pir": {
"languageName": "Arrr! Pirrrates",
"menu": {
"shortcuts": [
{
"identifier": "ds",
"name": "\u003ci class='fa-fw fab fa-github'\u003e\u003c/i\u003e GitHub repo",
"url": "https://github.com/McShelby/hugo-theme-relearn",
"weight": 10
},
{
"name": "\u003ci class='fa-fw fas fa-camera'\u003e\u003c/i\u003e Showcases",
"pageRef": "showcase/",
"weight": 11
},
{
"identifier": "hugodoc",
"name": "\u003ci class='fa-fw fas fa-bookmark'\u003e\u003c/i\u003e Cap'n Hugo Documentat'n",
"url": "https://gohugo.io/",
"weight": 20
},
{
"name": "\u003ci class='fa-fw fas fa-bullhorn'\u003e\u003c/i\u003e Crrredits",
"pageRef": "more/credits/",
"weight": 30
},
{
"name": "\u003ci class='fa-fw fas fa-tags'\u003e\u003c/i\u003e Arrr! Tags",
"pageRef": "tags/",
"weight": 40
}
]
},
"params": {
"landingPageName": "\u003ci class='fa-fw fas fa-home'\u003e\u003c/i\u003e Arrr! Home"
},
"title": "Cap'n Hugo Relearrrn Theme",
"weight": 1
}
}
}
Read more about hugo menu and hugo 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:
-
Make the page file for the shortcut a headless branch bundle (contained in its own subdirectory and called
_index.md
) and add the following frontmatter configuration to the file (see exampleSite’scontent/showcase/_index.en.md
). This causes its content to not be ontained in the sitemap.+++ title = 'Showcase' [_build] list = 'never' publishResources = true render = 'always' +++
--- _build: list: never publishResources: true render: always title: Showcase ---
{ "_build": { "list": "never", "publishResources": true, "render": "always" }, "title": "Showcase" }
-
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 atitle
as this will cause it to be shown in the breadcrumbs - a thing you most likely don’t want.+++ [_build] list = 'never' publishResources = false render = 'never' +++
--- _build: list: never publishResources: false render: never ---
{ "_build": { "list": "never", "publishResources": false, "render": "never" } }
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.+++ title = 'Credits' +++
--- title: Credits ---
{ "title": "Credits" }