In my process of taking advantages of the page resources feature, I’ve run into some frustrating issues that I haven’t been able to figure out.
Currently running on the following from Homebrew:
hugo version
Hugo Static Site Generator v0.38.2 darwin/amd64 BuildDate:
I’m attempting to reference some static image files within a sub-folder of content. (as a branch bundle) I realize in order to reference anything within the markdown of any page, I would have to use a shortcode which would then be able to access the context of that particular page.
So for instance, I have this simple line in the shortcode html file:
{{ $img := $.Page.Resources.Match (.Get 0)}}
When evaluating {{$img}} it has always come up as an empty array.
I’m calling that shortcode in the markdown file in question (_index.md) as follows:
{{< file "*test*">}}
The intended file I’d like to find according to the resources I’ve set is test.png
I’ve set all of that up in the front matter as follows:
I’m having no luck. Even if I change the shortcode directly to something like this
{{ $file := $.Page.Resources.Match "*"}}
or
{{ $file := $.Page.Resources.Match "**"}}
I still get an empty array. The .Match function searches by name: correct?
Are there any configuration flags or anything that I have to do to outside of setting resources:, placing the files in the appropriate places and using the shortcode structure that I’m missing? Is the shortcode referencing the correct page context?
Ok. So Branch bundles cannot have page resources? I’ve seen conflicting examples maybe because they were incomplete. (and thus me writing this in the first place!)
I see now that the page resource is populating after changing over to index.md.
That is ALSO true, but in your case it was the /images sub-folder.
So “branch bundles” are sections and taxonomies; they are nested by nature. They cannot be nested inside a bundle.ges
You can, however, do (.Site.GetPage "section").Pages.