Accessing current post's URL?

I need to have a reference system in place. From the little I could understand, markdown is not very flexible on that front so I figured I’d have to resort to dirty old HTML for that, which I’m ok with:

my text needing a reference, blablabla [<a href="#my_ref">MY_REF</a>]


# References
* [<a id="#my_ref">MY_REF</a>]

The problem is that the reference to my_ref doesn’t work because Hugo builds the link based on the base folder. I can fix it by replacing the link by

my text needing a reference, blablabla [<a href="#post/my-post-url/#my_ref">MY_REF</a>]

but that means that if the page title / url ever changes then I’m screwed. Is there a variable I can use to always refer to my post’s URL?


Why not use markdown footnotes?

1 Like

You can use the new markdown hooks and create your own render-link.html template.
The templete can fill a scratch variable with the links. At the end of your page template you can check this scratch variable and generate the reference list.

I use a external tool to check all generated links. Was faster to implement :wink: