I want to add a header link before all h2 elements in my blog post pages.
I’m currently doing this with JS here, and you can see a demo of what I’m talking about here.
But I’d like to do this with Hugo if possible and reasonable.
A brief summary of how I’m doing it in JS:
- Create an anchor element that will contain the header link svg (which is replaced later by Feather)
- Get all h2 headings on the page
- For each h2, give the anchor href the id of the header, then add the anchor before the header text
Any ideas/examples of how to do this in Hugo are appreciated.