Hi guys,
I’m a beginner with Hugo and I really like it. I’ve got a probably simple question, I looked for an answer way too long and I cannot find what I’m doing wrong.
I’ve got an image (boat.jpg) together with an index.md file in the same content directory. Inside the single.html template I want to access the image url in a single line. Like:
<img src="{{ (.Resources.GetMatch "boat.jpg").RelPermalink }}" />
But this gives the following error:
render of "page" failed: "C:\c\sites\bb\layouts\_default\single.html:24:39": execute of template failed: template: _default/single.html:24:39: executing "main" at <"boat.jpg">: nil pointer evaluating resource.Resource.RelPermalink
While writing it like this does work fine:
{{ with .Resources.GetMatch “boat.jpg” }}<img src="{{ .RelPermalink }}">{{ end }}
What is the difference, and can I make the first method working?
Thnx in advance