Handle external links with Render Hook Templates

Yes. But if this was my blog, I would write every relative URLs in markdown like this:

[a link](/blog/mypost.md)

And every link out to the world like this:

[a link out on the internet](https://example.org/some-external-link)

Note that I have kept the link as a filename (mypost.md); that way I guess the links will also work when browsed on github.com.

I would probably also write variants of the above like this:

[a link](../blog/mypost.md)

And then use .Page.GetPage in the hook template for every non-external link.

If you do this and then use .Permalink for all your linking, there should be no need for canonifyURLs (I think…)

3 Likes