[solved] Assigning metadata "name" to a resource exclude it from .Resources.Match

It appears that resources with metadata name assigned to it (resources in Front Matter) will not be found by .Resource.Match

{{ range .Resources.Match "**.pdf" }} will find all my pdf, except those falling under a “resources” rule in the Front Matter with a name metadata

    - src: documents/checklist.pdf
      name: Document Checklist
      params:
        ref: '90564572'

checklist.pdf is out.

Maybe something to do with Match checking .Name?

Same with ByPrefix.

Yes. I think that’s a feature. Setting name for resource(s), I believe, acts like “soft renaming” those resources to the name specified by name. I learnt that from this example… especially this part:

[[resources]]
src = "*.png"
name = "my-cool-image-:counter"
title = "TOML: The Image #:counter"

I interpreted that as Hugo “soft-renaming” the first found .png file as my-cool-image-1, the second found .png file as my-cool-image-2, and so on (:counter is a special placeholder). Those images can then be collected using the .Match using something like my-cool-image-*.

May be you intended to use the title front-matter parameter instead of name?


Update: Actually this commit message says that:

Name will get its default value from the base filename, and is the value used in the ByPrefix and GetByPrefix lookup methods.

(which now extends to .Match and .GetMatch v0.34 onwards)

Yes. I think that’s a feature.

It make sense I think

We shouldn’t use name for something fancy.

Thanks!