I’m trying to add a section to the bottom of my posts to include a bunch of images. I may gussy it up later, but right now the problem I’d like to solve is that I want to be able to dump pictures into static/images with the correct filename and have them show up on the correct post. Ideally without managing lots of file structures (such as in bundles).
I don’t think it’s possible to use .Resources.Match to search the static folder, but I’m not sure what else to use? For example:
{{ $name := .File.BaseFileName }}
{{ $searchName := (printf "%s%s%s" "images/" $name "**") }}
{{ with .Resources.Match $searchName }}
{{ range . }}
<img src="{{ .RelPermalink }}">
{{ end }}
{{ end }}
You can place your images in the assets directory, and then they will be available as global resources using resources.Get and resources.GetMatch.
{{ resources.Get "images/a.jpg" }} --> returns single image
{{ resources.Get "images/*.jpg" }} --> error
{{ resources.GetMatch "images/a.jpg" }} --> returns single image
{{ resources.GetMatch "images/*.jpg" }} --> returns single image (the first one to match)
Unfortunately there is not a global equivalent to .Resources.Match to obtain multiple global resources.
This would allow you to create a Page Bundle anywhere in your content dir which would systematically (but only) publish its resources regardless of their .RelPermalink being invoked in your template. This would then act like a static directory but you could use .Resources.Match to find stuff in it.