Hi there!
I built my blog some time ago in hugo and loved it.
Now, I also use it to post my photography on there.
Until now I did this in the very tedious way of linking every image separately.
I would love to have a shortcode I could just insert in the index.md file that ranges over the images inside the bundle, but I can’t seem to get it to work.
I’ve made a layouts/shortcodes/photopost.html:
{{ with .Resources.Match "**.jpg" }}
{{ range . }}
<img src="{{ .RelPermalink }}">
{{ end }}
{{ end }}
I’m sure this looks very amateurish (which I totally am) but I thought that this would be an easy enough introduction into the working of shortcodes.
I think I get the basic idea: get the resources from the bundle, range over them, make it into a shortcode and use it in the index.md file from the relevant bundle.
Any help would be greatly appreciated
I don’t know your structure, but if the images are bundled you can put your code in single.html after {{- with $.Resources.ByType "image" -}} or even as a block without needing to touch index.md or create a shortcode.
So instead of creating a shortcode just creating a single.html template? That’s a good idea, I’ll try to get that one to work.
So {{- with $.Resources.ByType "image" -}} would call the images in the bundle (even if they’re in a seperate subfolder?) and then I can range over them?
Thanks for the tip!