Taxonomy image resources coming back nil


I’m trying to access the image associated with a taxonomy I’ve called “albums”, but it’s not appearing. I am able to pull the title from the meta data, however.

I’ve structured my albums taxonomy content like this:

├── album-1
│  ├──
│  └── header.png
└── album-2
   └── header.png

And I am trying to access the data in a home.html template like this:

      {{ $albums := "albums" }}
      {{ with ($.Site.GetPage (printf "/%s" $albums)) }}
        {{ range .Pages }}
          {{ $headerResource := .Resources.GetMatch "header.png" }}
            <a href="{{ .Permalink }}">
              <h3>{{ .Title }}</h3>
              <img src="{{ $headerResource.Permalink }}" alt="">
        {{ end }}
      {{ end }}

I’ve tried a several different approaches but just can’t seem to get anything but nil returning for $headerResource.

Any help would be greatly appreciated.
Thanks in advance!


  1. Do you have albums defined in your config.toml taxonomies?
  2. Try wrapping the .Resources part in a with:
{{ with .Resources.GetMatch "header.png" }}
   <img src="{{ .Permalink }}" alt="">
{{ end }}

Failing those, do you have your code in a repo we can look at? We don’t need the full project, just enough dummy content and layouts to illustrate your issue.

Using with via the snippet above fixed it! Thanks so much, @pointyfar.

Also, yes, albums is defined in config.toml.