.Page.Resources.GetMatch can't find files in subfolders

I have a “music” folder in my main content directory, and I have a shortcode for embedding mp3s. I want to keep the mp3s in a subdirectory of the ‘music’ folder called ‘audio’.

content/
     └── music/
            ├── song1.mp3
            ├── _index.en.md
            ├── _index.es.md
            └── audio/
                   └── song2.mp3

In this example, the code .Page.Resources.GetMatch “song1.mp3” returns the proper result, but .Page.Resources.GetMatch “audio/song2.mp3” returns nil.

I want to keep the files in the audio subdir, not the root music folder. What am I doing wrong?

See: Page bundles | Hugo

Where can the Resources live?

Only in the directory level of the branch bundle directory i.e. the directory containing the _index.md (ref).

Thanks—not sure what the asterisks represent in this answer?

I think maybe this is one of those cases where I’m better off rethinking my structure to suit the way Hugo prefers to organize things.

@zachy9 _index.xx.md is a list page, which means you must have your page resources on the same level as your _index.xx.md file. You cannot have them in a subdirectory. This is in the docs I link to above.

If you want to/have to organise your page resources in a subdirectory, create a headless page for it, ie music/audio/index.md and then .GetPage that page, then get that page’s resources.