Hi everyone!
I building my first Hugo website from the scratch and currently trying to embed image in the template of the page, so that I could add its path via frontmatter parameters, however, I get error (below).
To add image I am using code from a theme that I used before, it looks like I can re-use it but I don’t get why it doesn’t work.
Error:
execute of template failed at <add `assets/` .image>: error calling add: can’t apply the operator to the values
Template:
{{range .component}}
<div class = "max-w-[18rem]">
{{ if fileExists (add `assets/` .image) }}
{{$img:= resources.Get (.image) }}
{{$img:= $img.Resize "300x webp"}}
<img loading="lazy" decoding="async" src="{{$img.RelPermalink}}" alt="">
{{ end }}
Frontmatter
component:
- image: "images/diff_icon_04.webp"
Any help is appreciated, thanks!