Newbie help: cannot get .Resources to work?

Hey, so I’m trying to render an image in a page bundle and looking at the docs tried various formats:

{{ with .Resources.GetMatch "jst-pin.png" }}

<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">

{{ end }}
{{ $image := .Resources.GetMatch "jst-pin.png" }}

<img src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}">
{{ with .Page.Resources.GetMatch "jst-pin.png" }}

But it does not interpret the {{ $image := .Resources.GetMatch "jst-pin.png" }} tags, it just renders them as text.

thought maybe a theme issue, tried different ones - same. I must be missing somehing obvious?

My content strcuture:

content
  posts
     test-post
        index.md
        jst-pin.png
hugo v0.119.0-b84644c008e0dc2c4b67bd69cccf87a41a03937e+extended darwin/arm64 BuildDate=2023-09-24T15:20:17Z VendorInfo=brew

Are you placing the template code in a markdown file, instead of placing it in a template?

1 Like

ok, now I understand. No templates in the markdown, just the shortcodes. The problem was that googling “hugo images” brings up Image processing | Hugo so I copy pasted, but was not familiar with differences between templates and markdown.

thank you!

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.