Resources not found

Hi all! I’m new to Hugo and I’m trying to add an image to my post template.

So I have two files in my content directory: test.md and test.jpg.

In the frontmatter for test.md I have the following resource defined:

resources:
- name: header
  src: test.jpg

And in my template I have:

{{ with .Resources.GetMatch "header" }}
  {{ .Fill "600x400" }}
  <img src="{{ .RelPermalink | relURL }}">
{{ end }}

However, no image is displayed. I also don’t get an error, just nothing happens. I’ve been trying a bunch of things but I can’t seem to figure out how to make my resources work. Can anyone with some more experience help me out with this?

Hey,

You are not alone in finding this hard to work/understand.

I think you need to read this section:

In short: If you rename test.md => index.md you should get close to what you want.

3 Likes

Awesome, thanks! Nowhere on the Page Resources documentation does it link to the Page Bundle docs or does it mention you need to set them up for the resources to work, perhaps that’s why people have trouble to get it to work?

In any case, I got it working now. Thanks for your quick response!

2 Likes