Hello. I’m trying to learn the lookup order, but what I cannot understand is if I put a content/contact.md
(form this doc Template lookup order | Hugo) page into a menu (menus: top
), it does not appear in the menu, nor in the sitemap. Are there any special conditions for the Page
Kind
? Thank you
There are no special conditions that would not show a page in a menu based on template lookup order.
Please explain how you “put content/contact.md
into menu: top
”. I assume you do that via frontmatter (not via configuration file). Then show where you render the top
menu. Also show the full frontmatter menu item. If you have some form of parent setup this might lead to it disappear if your template does not show subitems.
So check two things:
- is the page properly added to the menu?
- how is the menu rendered?
This has nothing to do with template lookup order… or you missed a detail. I could think of issues with multilanguage sites that define a menu per language.
But in summary: It’s probably a configuration issue.
Thank you for the reply.
- Yes, I define the menu in the front matter;
content/contact.md
contains:
---
title: Contact Page
menus: top
---
# A contact page
Then I have a partial file (at layouts/partials/nav.html
) that is meant to render the menu:
<div>
{{ printf "%#v" site.Menus }}
{{- range site.Menus.top}}
<div><a href="{{ .URL }}">{{ .Name }}</a></div>
{{- end}}
</div>
The nav.html
is then included in the layouts/_default/single.html
:
<body>
<div id="nav">
{{ partial "nav.html" . }}
</div>
</body>
Besides that, the configuration is default, I haven’t touched the hugo.toml
apart of changing the title
and baseURL
props.
And what I have found, is if I move the content/contact.md
file to content/whatever_folder/contact.md
it will appear in the menu.
That’s what made me thinking there’s some nuance I’m not catching.
I think it’s worth noting, that my content
folder has only 2 files content/index.md
and content/contact.md
. As soon as I rename the index.md
to the _index.md
everything breaks with error rendering taxonomy.
Ok, I figured it out. I found that index.md
and _index.md
declare the tree structure. I now know where to look.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.