Environment
hugo v0.87.0+extended linux/amd64 BuildDate=unknown
Issue
I’m trying to write a shortcode to insert images on pages so I can process them. I’m not using page bundles for content so I can’t use .Resources.GetMatch
and resources.Get
is just not working.
On the page…
{{< image src="/img/subdir/image.jpeg" alt="Description" width="640" height="400" >}}
Inside the shortcode…
…this work as expected:
{{ $src := "image.jpg" }}
{{ $image := resources.Get $src }}
<img src="{{ $image.RelPermalink }}">
while this doesn’t:
{{ $src := .Get "src" }}
{{ $image := resources.Get $src }}
<img src="{{ $image.RelPermalink }}">
throwing this error:
Error: Error building site: "/site/content/my-page.md:56:1": failed to render shortcode "image": failed to process shortcode: "/site/themes/my-theme/layouts/shortcodes/image.html:8:18": execute of template failed: template: shortcodes/image.html:8:18: executing "shortcodes/image.html" at <$image.RelPermalink>: nil pointer evaluating resource.Resource.RelPermalink