Linking figure to page

I have read the documentation for figure shortcode but still not sure if I can use it to link a picture to a page. Is it possible?

My plan is to eventually have a page with a few side-by-side pictures acting like a menu. Users clicking a picture will be taken to its linked page.

Thanks for your time.

You can customise the figure shortcode and wrap it in a link.

Thanks for the response. I am new to hugo and not knowledgeable enough to customise shortcodes. However, will give a go if I am provided with a clue or two.

Regards,

The default internal figure shortcode already contains a link attribute (I hadn’t noticed as I don’t use it).

Therefore you can generate the link simply by using the following input in your Markdown files:

{{< figure src="/media/spf13.jpg" link="https://example.com">}}

For a complete list of the input parameters that are available for the figure shortcode please refer to the documentation.

If for some reason you need to modify the internal figure shortcode further, you can override it by copying the contents of the template in the above link and save them in your project as /layouts/shortcodes/figure.html

1 Like