Undocumented required parameters for menu items?

I don’t know anything about golang, so the following might be completely obvious and redundant, apologies if that’s the case.

I tracked down a little bug in a site I’m building that was caused by the following behaviour, which I’m pretty sure is undocumented:

[menu]
    [[menu.main]]
        title = "first item"
        url = "https://example.com/first"
        post = "whatever description"
    [[menu.main]]
        title = "second item"
        url = "https://example.com/second"
        post = "whatever other description"

Only one of these items will show up in .Site.Menus.main. However, when each item has at least one of name or identifier defined, both will appear. I haven’t tested all the variations of this, since I’m sure this behaviour is known. But there’s no reference to it in the current version of the docs, so far as I can tell. I was only able to solve the problem by working backwards from the example menu-entries given in the docs.

I suppose this happens because whatever entity the above toml is parsed into (or the parser itself, idk) depends on the presence of at least one of name or identifier (perhaps there are other alternatives?) to distinguish between menu items. If I had more golang under my belt I’d be less lazy and go and look for the implementation, but I don’t have time for that just now. My question for the moment is: what exactly is the constraint here, and shouldn’t it be clearly stated in the documentation? i.e.

note that every non-content menu item must have at least one of the properties name or identifier

that’s all! if it’s a good idea I’ll make my first pull request to the documentation.

1 Like

Do that. It makes sense to mention it. It is implicitly talked about in a far hidden part about nesting of navigations. Basically a menu item needs an identifier. If the menu item is automatically created from a post/page then the identification is easy (the markdown file). Your config.toml menu is more or less the step child of a proper navigation.

It might even be more like:

.Identifier > .Name > .LinkTitle > .Title

The omission is probably because the documentation is still written from a very “developers mind” and omits what is obvious to someone with “intimate” knowledge of the code. It’s obvious that there needs to be some form of identification.

Having said all that, it is written about in the documentation :wink: just very hidden and not in the introduction to menues:

Selection_143

I still think that it should be mentioned on a more prominent place in addition to this.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.