Page Resources Not Populating

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 ( 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:

- src: "images/test.png"
  name: test

Here is the file structure.

└── project
    ├── images
    │   └── test.png

I’m using the _index file underneath the project directory.

Any insight on this would be helpful. I’ve read and re-read the documentation but it’s not so clear what I’m doing wrong.

Use the super asterisk… so: {{< file "**test*" >}}.


Hey @kaushalmodi, thanks for the reply.

I’m having no luck. Even if I change the shortcode directly to something like this

{{ $file := $.Page.Resources.Match "*"}}


{{ $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?

Btw, I’m running the local server with:

hugo server -D --disableFastRender

Ah, OK. I missed that the first time. You need to use .GetMatch in that context.

Nevermind. I think that as bep said, it’s difficult to say anything for sure without looking at your site source.

See another related post on that:

It is referencing a page, but it is … impossible to tell if it is the page with the resources without seeing the source.

Hi @bep,

Here’s an example:

If you navigate to http://<local path>/glob/ that should give you an idea of what I’m trying to do.

OK, now I understand:

You need to read up on the difference between branch and leaf bundles.

This needs to be renamed to “” if you want ot access resources in subfolders.

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

Thanks for your help.



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.

1 Like