DEV Community

Precious Chicken
Precious Chicken

Posted on • Originally published at preciouschicken.com on

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

Top comments (0)