Anchored headings in Hugo

If you want to have anchored headings in Hugo (e.g. having a # before each headings that links to the heading directly), this is how you do it (found in a post on hugos forum ).

Create a layouts/_default/_markup/render-heading.html and put the following code in it:

<h{{ .Level }} id="{{ .Anchor | safeURL }}">
    <a class="heading-anchor" href="#{{ .Anchor | safeURL }}">
	{{ strings.Repeat .Level "#" }}
    {{ .Text | safeHTML }}
</h{{ .Level }}>
Edit this page on GitHub

Links to this note