[SOLVED] List.html with content and resources of _index.md

The title pretty much sums it up.

I am trying to use resources defined in _index.md on the list.html template.

Using {{ .Content }} works fine, but the code below fails silently with hugo 0.39

{{ with .Resources.GetMatch "header" }}
  <img src="{{ .Permalink }}" alt="">
{{ end }}

From brief testing I cannot reproduce this at least on the latest Hugo master. Do you want to share your site source?

Put debug statements… e.g. do a and b get printed?


x
{{ with .Resources.GetMatch "header" }}
    a
    <img src="{{ .Permalink }}" alt="">
    b
{{ end }}
y

Without knowing your filenames etc, the title cannot sum it up.

After testing I realised that Hugo was not listing the header file because it was placed inside images/.

Moved into the root of the section and it’s working.

You didn’t need to do that. You can just use the “super asterisk” (**) assuming that that images/ dir is inside that bundle too.

So "**header" instead of just "header".

1 Like