HUGO

Getting multiple page resources to have the same source

Is it possible to reference the same file when listing resources on a page’s frontmatter?

---
...
resources:
  - src: filename.jpg
    name: name1
    title: title1
  - src: filename.jpg
    name: name2
    title: title2
---

I’ve actually tried this and it sets the metadata of the first entry that matches the path, name1 as a name for the resource, in this case.

An example use case would be to use the same image both in a carousel and as a single image, and wanting to access it as two separate resources with different metadata.

Thanks in advance!

I think, but did not test it right now, that the matching is done on the name, not the filename if both are available. The way you describe your blackbox tells me, that there could be an issue in the way you match (“the first entry”). But as long as you don’t show the code you are using to retrieve your resource I am not using my brain :slight_smile:

There is Match and getMatch and you might want to read up on their differences (one returns “the first entry” (hint) and one returns all):

Oh, and @regis wrote about that too.