I got this working. I think the important thing to note, is that your resources page must be a leaf bundle:
Therefore, /media should live at content/media/index.html. If that is what you’re already doing, can you please upload a sample repo on GitHub or GitLab?
Well first of all, thank you for proving me wrong : GetMatch works fine with current implementation of the variable.
In the example I have provided there was an issue (I guess I rushed the code), which when rectified works perfectly (working copy is on a branch called “working” --> https://gitlab.com/nikola.ffw/hugo-match-issue/tree/working).
This then tells me I need to go back and check what I did wrong in my master project - the one where this error originated from, but at least now I know that it does work.
So thank you very, very much for your input and help!
Well,
the issue is there if I take the working code and put it in a block like so:
Any idea why this might cause it to break?
Edit: Actually it works fine while the Hugo server is running and the changes are made, but each subsequent run of the server causes the error to show up. It’s quite strange.
I’ve solved this one by not trying to match the specific resource name with the use of GetMatch, but rather load all of them using {{ $resources := $page.Resources.ByType "image" }} and then sorting them out with where command.
Ref. --> [SOLVED] Media in separate folder and accessing with Page Resources