Linking to a heading in the same page in Hugo

preciouschicken

Precious Chicken

Posted on February 20, 2022

Linking to a heading in the same page in Hugo

Linking to another page in markdown in Hugo is easy: i.e. [Auntie Beeb](https://www.bbc.co.uk/) renders as Auntie Beeb - but when you want a link to a heading in the same page I can never remember, so this is a quick aide-memoire:

HTML

In HTML a relative link to an element in the same page looks like:

<!-- <a> element links to the section below -->
<p><a href="#Section_further_down">
  Jump to the heading below
</a></p>

<!-- Heading to link to -->
<h2 id="Section_further_down">Section further down</h2>
Enter fullscreen mode Exit fullscreen mode

Hugo markdown

In Hugo to achieve the same effect:

<!-- <a> element links to the section below -->
[Jump to the heading below](#section-further-down)

<!-- Heading to link to -->
## Section further down
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
preciouschicken
Precious Chicken

Posted on February 20, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related