Is there a way to add the name of a variable to the configuration and then retrieve that variable in a layout? In this specific case (would want to know a very generic way though) I want to configure for instance, what slice or dict to range through inside of a footer sidebar.
The idea is this:
config
footerlists = ["list1", "list2", "list3"]
and in the footer:
{{ range $config.footerlists }}
{{ range ( getDict . ) }}
do something
{{ end }}
{{ end }}
A very rudimentary way would probably involve the index function but in that case I would need to know what the “root” of the index (site, a menu, whatever) should be and that might differ?
The problem I am having is to apply an available variable while having the “reference” (if that is the term for that) only as a string.
The other version you suggested I have working at the moment, but for it to work it all needs to be for instance defined as menu in the configuration. I want to vary between configs and menus and maybe a getPage functionality (for some logo/text in the footer or sidebar) or basically anything.
{{ index (where (.Scratch.Get "employees") "id" "002") 0 "name" }}
Maybe you can put everything you might need into page-scoped scratches?
Index Equivalents
One thing I sometimes forget about index… these are equivalent:
{{ site.Params.foo.bar.baz }}
{{ index site.Params.foo.bar "baz" }}
{{ index site.Params.foo "bar" "baz" }}
{{ index site.Params "foo" "bar" "baz" }}
Example
git clone --single-branch -b hugo-forum-topic-32412 https://github.com/jmooring/hugo-testing hugo-forum-topic-32412
cd hugo-forum-topic-32412
hugo server
Files of interest:
config.toml
layouts/_default/baseof.html (scratches set here)
layouts/partials/footer.html (putting stuff into maps)
layouts/_default/single.html (calls the partial)
View the bottom of any of the content pages to see the two jsonified maps.
The structures of the two maps are different, which will be a challenge if you blindly range through your list of collections. If you need to normalize the structures, you could do it in the partial, or when you create the scratches.
I think this approach is a bit fragile and has a lot of moving parts, but I couldn’t come up with anything better.