Dear Hugo fans!
I would like to build an image gallery (based on the new Resources
) without any trance in the source code of the index.md file.
Images are no problem:
{{ with .Resources.Match "gallery-image*" }}
<div class="gallery">
{{ range . }}
{{ $image := .Fill "400x400" }}
<figure><img src="{{ $image.RelPermalink }}" alt=" "></figure>
{{ end }}
</div>
{{ end }}
But how is it possible to add captions. My idea is to use seperate .txt files containing the captions:
── blog-article/
│ └── gallery-caption01.txt
│ └── gallery-image01.jpg
│ └── gallery-image02.jpg
│ └── gallery-caption03.txt
│ └── gallery-image03.jpg
│ └── index.md
Reading them is not possible this way:
{{ range .Resources.Match "gallery-caption*" }}
{{ .RelPermalink | readFile | safeHTML }}
{{ end }}
For readFile
you obviously need to point to the source (content/blogname/blog-article) of the txt files. RelPermalink
or Permalink
does not work.
And how do you combine the ranges, so that Hugo reads the content of gallery-caption03.txt
only within the range for gallery-image03.txt
.
Thank you very much!