What is the syntax for getting to the property of a single menu and its .URL property from the config? I believe I using where with “Identifier” gives me the menu, but I get an error when I try to use the property. Being new to this, I think I am missing something basic.
{{ $programsMenu := where .Site.Menus.main “Identifier” “programs” }}
causes no error but trying to get at $programsMenu.URL does. If there is a docs page I am missing that goes over this I would love to read through it. The examples I have come across so far all use range, but I only need a single url for a button in a sidebar. I can hardcode it but I shouldnt. Thanks!!
A Menu is a slice, and currently there are no lookup methods on it (if you would create a GitHub issue that would be great).
You could create a range and if construct and pick your menu item, but I would just hardcode it and wait for a fix in the mentioned GH issue you will hopefully create.
The index is a built-in func from the Go templates (or, it really isn’t: There is a bug in the original, so we have made a temp port and fix, we will remove our duplicate when Go 1.8 arrives or so), and those are mainly documented as part of Go’s doc.