Any way to use the src key in frontmatter page resources?

I’m trying to see if there is a way to use the src key from the resources metadata frontmatter structure, shown below.

It appears, that the only function it has is to identify which particular file, should it come up in the templates, should be given whatever metadata. But it seems like it’s not really made for using directly. I guess i’m trying to not have multiple keys in the frontmatter that point to images, one where it says what images to use

images: ['a.png', 'b.png', 'c.png']`
resources:
  - src: a.png
    title: A
  - src: b.png
    param:
       - alt: B
  - src: c.png
    title: C

Basically, can i just not have the images: key and use the src directly from the resources?

I’m using the images: because that’s what is default in Hugo and used by the internal SEO partials to loop through a slice of images for sharing. But I guess i don’t have to use images:, and I could always modify the internal partials.

Thoughts?

PS: Will Hugo look in Page Bundle for the resource listed in src and if not found look in /assests/ or does it stop at the Page Bundle? Is there any way to get the frontmatter metadata to work on things in /assests/?

It’s a page resource which means that Hugo will do something to it. The nearest to using the src is .Permalink, but this oftentimes has processing particles in it in addition to the original file name. Because the file in question is “worked on” there is no reason to have its value available in the template.

Having said this: Have a look at .Name for the page resource. Without being set it’s the file name (src). If you set it you can use it in your templates. It’s probably enough to just replace src with name. There is more to it (like “select where name is like ‘something*’” - not real template code, but you get the direction its going?). The look at the methods for page resources to get more ideas.

No. If it’s not found in the page bundle then it’s not there for Hugo. You have to implement this functionality yourself with an if.

I did a little experiment this morning and learned that if i do something like

{{ range .Params.resources }}
  {{ .src }}
{{ end }}

It does actually write out what’s listed in src for each element. So in this sense it could be used as the path. And of course there is the “name” key also, which when set, seems to disable the usage of the path for that specified source. Like, you can no longer reference it by the path you must reference it by the name. Not sure if that’s expected behavior but that’s observed behavior.