Hi everyone! Hugo noob here, this is my first post so a few words first… Loving the system and finding the documentation to be REALLY robust - so, to all maintainers/advanced users, THANK YOU!
Second thing before I dive into details… This is a LONG post - I tried to make my question as clear and well illustrated as possible. If you’re looking for a TL;DR of this post, scroll to the bottom of the post and read the Conclusion section which outlines a summarised list of the actual questions I’m asking.
Third/last before continuing: THANKS IN ADVANCE!!! to whomever can help me figure things out here! ![]()
Alrighty… I’ve read over the Menu documentation. My question is either straight forward and simple OR, I may be encountering a bug with the latest version of Hugo… ![]()
What I was hoping: I was hoping that sectionPagesMenu would (with the “default” recursive template provided in the documentation) automatically generate nested menus.
What is happening: Only top level items are being rendered/picked up. When I dump site.Menus.main (using a <script> tag to view JSON rendering of site.Menus.main) I can see that top (top section) Menu objects that should have child items (site structure follows below), don’t.
Site/Content Structure
content/
├── _index.md
├── about.md
├── privacy-policy.md
├── terms-and-conditions.md
├── artwork
│ ├── _index.md
│ └── art-piece-00
│ ├── img
│ │ ├── primary
│ │ │ └── primary_768x1024_00.jpg
│ │ └── secondary
│ │ │ └── secondary_768x1024_00.jpg
│ │ │ └── secondary_768x1024_01.jpg
│ └── index.md
└── updates
├── _index.md
├── event1
│ └── index.md
├── event2
│ └── index.md
└── event3
├── _index.md
└── subevent1
├── event4.md
└── event5.md
JSON Dump of site.Menus.main
[
{
'Identifier': '',
'Parent': '',
'Name': 'About',
'Pre': '',
'Post': '',
'URL': '',
'PageRef': '',
'Weight': 0,
'Title': 'About',
'Params': null,
'Menu': '',
'ConfiguredURL': '',
'Page': {
'Date': '2024-02-27T22:46:56-05:00',
'Lastmod': '2024-02-27T22:46:56-05:00',
'PublishDate': '2024-02-27T22:46:56-05:00',
'ExpiryDate': '0001-01-01T00:00:00Z',
'Aliases': null,
'BundleType': '',
'Description': '',
'Draft': false,
'IsHome': false,
'Keywords': null,
'Kind': 'page',
'Layout': '',
'LinkTitle': 'About',
'IsNode': false,
'IsPage': true,
'Path': '/about',
'Pathc': '/about',
'Slug': '',
'Lang': 'en',
'IsSection': false,
'Section': '',
'Sitemap': {'ChangeFreq': '', 'Priority': -1, 'Filename': 'sitemap.xml'},
'Type': 'page',
'Weight': 0,
},
'Children': null,
},
{
'Identifier': 'artwork',
'Parent': '',
'Name': 'Artwork',
'Pre': '',
'Post': '',
'URL': '',
'PageRef': '',
'Weight': 0,
'Title': 'Artwork',
'Params': null,
'Menu': '',
'ConfiguredURL': '',
'Page': {
'Date': '2024-02-27T22:46:56-05:00',
'Lastmod': '2024-02-27T22:46:56-05:00',
'PublishDate': '2024-02-27T22:46:56-05:00',
'ExpiryDate': '0001-01-01T00:00:00Z',
'Aliases': null,
'BundleType': 'branch',
'Description': '',
'Draft': false,
'IsHome': false,
'Keywords': null,
'Kind': 'section',
'Layout': '',
'LinkTitle': 'Artwork',
'IsNode': true,
'IsPage': false,
'Path': '/artwork',
'Pathc': '/artwork',
'Slug': '',
'Lang': 'en',
'IsSection': true,
'Section': 'artwork',
'Sitemap': {'ChangeFreq': '', 'Priority': -1, 'Filename': 'sitemap.xml'},
'Type': 'artwork',
'Weight': 0,
},
'Children': null,
},
{
'Identifier': '',
'Parent': '',
'Name': 'Privacy Policy',
'Pre': '',
'Post': '',
'URL': '',
'PageRef': '',
'Weight': 0,
'Title': 'Privacy Policy',
'Params': null,
'Menu': '',
'ConfiguredURL': '',
'Page': {
'Date': '2024-02-27T22:46:56-05:00',
'Lastmod': '2024-02-27T22:46:56-05:00',
'PublishDate': '2024-02-27T22:46:56-05:00',
'ExpiryDate': '0001-01-01T00:00:00Z',
'Aliases': null,
'BundleType': '',
'Description': '',
'Draft': false,
'IsHome': false,
'Keywords': null,
'Kind': 'page',
'Layout': '',
'LinkTitle': 'Privacy Policy',
'IsNode': false,
'IsPage': true,
'Path': '/privacy-policy',
'Pathc': '/privacy-policy',
'Slug': '',
'Lang': 'en',
'IsSection': false,
'Section': '',
'Sitemap': {'ChangeFreq': '', 'Priority': -1, 'Filename': 'sitemap.xml'},
'Type': 'page',
'Weight': 0,
},
'Children': null,
},
{
'Identifier': '',
'Parent': '',
'Name': 'Terms & Conditions',
'Pre': '',
'Post': '',
'URL': '',
'PageRef': '',
'Weight': 0,
'Title': 'Terms & Conditions',
'Params': null,
'Menu': '',
'ConfiguredURL': '',
'Page': {
'Date': '2024-02-27T22:46:56-05:00',
'Lastmod': '2024-02-27T22:46:56-05:00',
'PublishDate': '2024-02-27T22:46:56-05:00',
'ExpiryDate': '0001-01-01T00:00:00Z',
'Aliases': null,
'BundleType': '',
'Description': '',
'Draft': false,
'IsHome': false,
'Keywords': null,
'Kind': 'page',
'Layout': '',
'LinkTitle': 'Terms & Conditions',
'IsNode': false,
'IsPage': true,
'Path': '/terms-and-conditions',
'Pathc': '/terms-and-conditions',
'Slug': '',
'Lang': 'en',
'IsSection': false,
'Section': '',
'Sitemap': {'ChangeFreq': '', 'Priority': -1, 'Filename': 'sitemap.xml'},
'Type': 'page',
'Weight': 0,
},
'Children': null,
},
{
'Identifier': 'updates',
'Parent': '',
'Name': 'Updates',
'Pre': '',
'Post': '',
'URL': '',
'PageRef': '',
'Weight': 0,
'Title': 'Updates',
'Params': null,
'Menu': '',
'ConfiguredURL': '',
'Page': {
'Date': '2024-02-27T22:46:56-05:00',
'Lastmod': '2024-02-27T22:46:56-05:00',
'PublishDate': '2024-02-27T22:46:56-05:00',
'ExpiryDate': '0001-01-01T00:00:00Z',
'Aliases': null,
'BundleType': 'branch',
'Description': '',
'Draft': false,
'IsHome': false,
'Keywords': null,
'Kind': 'section',
'Layout': '',
'LinkTitle': 'Updates',
'IsNode': true,
'IsPage': false,
'Path': '/updates',
'Pathc': '/updates',
'Slug': '',
'Lang': 'en',
'IsSection': true,
'Section': 'updates',
'Sitemap': {'ChangeFreq': '', 'Priority': -1, 'Filename': 'sitemap.xml'},
'Type': 'updates',
'Weight': 0,
},
'Children': null,
}]
After searching around in the documentation, this forum and the net in general, I can’t find anyone saying that they’ve faced a similar issue. At first, I thought that perhaps page items were not being picked up by Hugo because they had draft: true in them; I then set draft: false in all *.md files; that didn’t work so I then deleted draft:... entirely from all MD files.
After reading a few posts (including this one), I tweaked the content folder dir structure a few times thinking that the issue might be because I didn’t understand the diff between Leaf and Branch bundles correctly. To clarify, the Updates section/Branch Bundle folder originally looked like this:
content/
└── updates
├── _index.md
├── event1.md
├── event2
│ └── index.md
└── event3
├── _index.md
├── event4.md
└── event5.md
But changing from the above to what I have currently (illustrated in the “Site/Content Structure” code block) didn’t make any difference… and I get the feeling that both versions should work correctly.
So… all said, I’m starting to suspect that the auto-generated menu that Hugo provides as a value for sectionPagesMenu doesn’t run recursively… which is why I’m reaching out for help. If it doesn’t generate recursive menus, it feels like a bit of a wasted opportunity.
Conclusion
To explain… the site I’m working on will have A LOT of “artwork” and “updates” pages, each living as a Leaf Bundle like so:
content/
├── _index.md # <-- This is the home page and is a Section/List Page, right?
├── artwork # <-- Branch Bundle?
│ ├── _index.md # <-- Section/List Page?
│ └── art-piece-00 # <-- Leaf Bundle?
│ ├── img # <-- All files within this directory are "Page Resources" right?
│ │ ├── primary
│ │ │ └── primary_768x1024_00.jpg
│ │ └── secondary
│ │ │ └── secondary_768x1024_00.jpg
│ │ │ └── secondary_768x1024_01.jpg
│ └── index.md # <-- This is a Single Page?
└── updates # <-- Another Branch Bundle?
├── _index.md # <-- List Page for the "Updates" Branch Bundle?
├── event1 # <-- Leaf Bundle
│ └── index.md # <-- Single Page
├── event2
│ └── index.md
└── event3 # <-- Branch/Section Bundle
├── _index.md # <-- Branch/Section List Page
└── subevent1 # <-- Leaf Bundle
├── event4.md # <-- Single Page (will this be rendered?)
└── event5.md # <-- Single Page (will this be rendered?)
- Could someone please confirm whether or not Hugo’s
sectionPagesMenu/site.Menus.mainvalue recurse through the site’s structure to generate a FULL and Children-Inclusive menu automatically? - If not, then, is there an automated way WITHOUT adding “menu/parent” values in individual Page front matter to “get” a fully recursive menu?
- If there isn’t currently an “out-of-the-box” solution for a fully-recursive menu, then is there a way to use the existing Hugo API to generate this structure without having to define menu structures in
YAML/TOML/JSONdata (be it in Site Config or within Page Front Matter)? PS: I know I could update variousarchetypetemplates to automatically set themenu: parent...values but am really hoping this isn’t necessary as it “feels” messy and prone to potential error - esp. because I’m developing this site for use by non-technical/non-coder users. - To whomever can help me out here - please let me know if I’ve understood the nature of each directory/file’s role in the code block above? Esp. with regards to
event4.mdandevent5.md? From some of the discussion threads I’ve read here, it looks likeLeaf BundlesEXPECT aindex.mdfile and ONLY THAT will be rendered as a valid, auto-indexed page. If this is the case, does that mean thatevent[4|5].mdwill not be rendered at all? OR, would they be consideredheadlesspages?