How to use the Hugo built-in figure shortcode with page ressources?

Hi! I’m trying to figure out how to use the Hugo built-in figure shortcode with a page resource (instead of pointing directly to the file). As I want to use it in a normal content markdown document of my website, as far as I understood, I cannot use something like

{{ $img := .Resources.Match "image" }}
{{< figure src="$img.RelPermalink" title="Lorem ipsum" >}}

directly in my markdown file.
I didn’t find a solution in the Hugo docs. And all the examples I found work by creating a new figure short code but I’m pretty sure there must be a possibility to make it work with Hugos default functions, which I failed to recognize so far. :thinking: Any help appreciated! :slight_smile:
Thx!

Yes, you must create a new figure short code.

Thanks for your reply! I see, too bad to hear. If Hugo proposes to use Page Resources, it seems reasonable to me, that the built-in functions support them. :slight_smile: Shall I open a feature request?

I don’t think so. The figure shortcode is not a function, it is an embedded template that is easily customized as needed.

1 Like

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