HUGO

Relative Markdown Links - Markdown Render Hooks

The minimal example for relative markdown links:

[My Article](../my-article/index.md)

Template: /layouts/_default/_markup/render-link.html

<a href="{{ (.Page.GetPage .Destination).RelPermalink | safeURL }}">{{ .Text | safeHTML }}</a>

For more complex example in the test project, follow: https://github.com/bep/portable-hugo-links

3 Likes

This solves the problem of relative markdown links to other pages not working for me.

To clear this up for people like me who were initially confused, you create the file /layouts/_default/_markup/render-link.html, then place that code in it.

Is it possible to get this to work for images as well. That is, if I have an image in my content folder and I make a relative link to it, it displays the image?