My initial requirement was to put # before h1 headings, ## before h2 heading, etc.
As others have mentioned, this can be achieved with render hooks. This is what I’m doing:
Put this in your theme’s layouts/_default/_markup/render-heading.html file:
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
<a class="heading-anchor" href="#{{ .Anchor | safeURL }}">
{{ strings.Repeat .Level "#" }}
</a>
{{ .Text | safeHTML }}
</h{{ .Level }}>