tl;dr I need to find my image based on the file stem (sans extension) in a template
I have images in static/images/
In the front matter (via archetypes) I have a parameter image that has the same name as the page (file stem, using image: {{ .Name }})
I am putting the image into my page via the template with: <img src="/images/{{ .Params.image }}.jpg"/>
So hugo new art/Name\ of\ Image.md creates a page that pulls in the image.
Except come images have jpg and some have png as suffix (being different formats)
So I need to do something different.
Is there a way I can search for them? Like <img src="/images/{{ find static/images/ .Params.image }}
It’s not possible to do in an archetype the way you’re going about it.
But, it may be possible in your template code. You could use readDir and find your image in the returned list
Is there a more idiomatic way of associating a image with a page, via the file name or front matter? (Not sure if I am using “page” correctly. Hopefully I am clear)
I thought the thing to do with images is to put them under /static. But then again page resources can be images. I am confused