I would like to create a gallery with thumbnails in a blog post, making use of the recently introduced image processing techniques of Hugo. I am also using NetlifyCMS to create blogpost and upload images, but I am having some difficulties to get it correctly configured.
I have had a look many pages, but I can only link 2 here (no permission for more):
What I would like to do is to specify a selection of images in the frontmatter of the blogpost and save them in a general media folder. In the blogpost partial I would construct the gallery with thumnails, specifying the media folder as base and then using only the images of the frontmatter of each blog post. Is something like this possible?
My folder structure looks like this:
content
images
_index.md (contains ‘headless: true’)
fire-start.png
blog
2018-04-29
_index.md
This code shows all images in the image folder:
{{ with .Site.GetPage "section" "images" }}
<h2>{{ .Title }}</h2>
{{ $resources := .Resources.Match "**"}}
{{ range $resources }}
{{ with . }}
<img style="max-width: 100%;" src="{{ .RelPermalink }}">
<br />
{{ end }}
{{ end }}
{{ end }}
But I would like to filter it for only the images from the frontmatter of the blogpost. Is that possible?
I would suggest you create a headless page bundle storing all your directories of images and then access it when needed using .GetPage
This way you get all the benefit of page resources without having to create a « visible « page for it. And it can sit at the root of your content directory for easy access from editors.
Thanks for your reply @regis. Is this not more or less what I have done in the example I gave? I struggle now to use .Resource.Match to get only the images from the frontmatter: