hermit icon indicating copy to clipboard operation
hermit copied to clipboard

Feature request: menu shortnames

Open mmahmoudian opened this issue 5 years ago • 1 comments

Issue:

The menus can be large multi-word text. Therefore in the mobile view they get bloated and even very large.

Suggestion:

I would like to propose that we have a tag under the [[menu.main]] in the config.toml to have also short name for the sections.

[menu]

  [[menu.main]]
    name = "Blog Posts"
    shortname = "Posts"
    url = "posts/"
    weight = 10

P.s: I have just started with Hugo and I'm new to it. I tried to modify the layouts/partials/ to have another file named menu-short.html but I got the following error:

		{{- range .Site.Menus.main }}
			{{- if .HasChildren }}
				<a href="{{ .URL | absLangURL }}" class="has-children">{{ .shortname }}</a>
				<span class="sub-menu">
				{{- range .Children }}
					<a href="{{ .URL | absLangURL }}">{{ .shortname }}</a>
				{{- end }}
				</span>
			{{- else }}
				<a href="{{ .URL | absLangURL }}">{{ .shortname }}</a>
			{{- end }}
		{{- end }}

Rebuild failed:

Failed to render pages: render of "section" failed: execute of template failed: template: _default/list.html:2:3: executing "header" at <partialCached "header.html" .>: error calling partialCached: "/Users/mehrad/Documents/Personal Projects/Personal CV/PersonalSite/themes/hermit/layouts/partials/header.html:10:41": execute of template failed: template: partials/header.html:9:8: executing "partials/header.html" at <partialCached "menu-short.html" .>: error calling partialCached: "/Users/mehrad/Documents/Personal Projects/Personal CV/PersonalSite/themes/hermit/layouts/partials/menu-short.html:10:41": execute of template failed: template: partials/menu-short.html:10:41: executing "partials/menu-short.html" at <.ShortName>: can't evaluate field ShortName in type *navigation.MenuEntry

mmahmoudian avatar Jun 28 '19 20:06 mmahmoudian

Maybe Hugo just doesn't allow using other string for menu configs. I'm not sure about this as my understanding about Hugo is very limited. I would suggest you seek help at the official forum.

Track3 avatar Jul 04 '19 12:07 Track3