Sorry, I want to foreach(range) all in the md-file and then access the key value pairs. I have got an image gallery and want to insert the images via a markdown file. I use the image gallery twice a page and do not want to repeat myself.
still not clear for me and trying to match your wording and code at some points does not shed light on .
get all custom params
I want to access all params at once.
There is much more code
code like .Params.headline and the outer range ???
@McShelby point ed you to range $k, $v did you check what the $k is?
page.Params returns a map of key value pairs
range iterates over that
your values are arrays you might want to process that with another range.
either step a little off the code and concentrate elaborating WHAT you want
dig in the real code and show what you have and what you are missing “IN DETAIL”
some points:
page.Params returns ALL front matter parameters,
use a subkey [params.gallery] with the arrays to separate and range over that one.
or use data files instead of front matter to store your image gallery data see site.Data
feels like there’s a lack of understanding templating language and data structures.
Sorry, I don’t get it neither. From my understanding, I still think my first reply solves your issue or at least gives you a head start.
But let’s try to get more specific:
Referencing to your sample front matter in your first post, what keys do you expect in your loop? Name all!
What should happen with this keys or their accommodating values?
If the value is by itself a collection, what should happen with each of the items in the collection?
I have “3” gallerys or say I want “3” gallerys. At the moment I have got “1”. Now I am looking for a way to template it, so I do not have to repeat myself.
I need this template also for other pages on the website… for sketches, photos and so on.
looks like writing your code in a a Partialor Shortcode will help you out.
you can parameterize both to show a specific gallery. if you need to use that in both, templates and shortcodes. create a partial and call it from within a shortcode.