# ToC with anchors in posts

**URL:** https://discourse.gohugo.io/t/toc-with-anchors-in-posts/19627
**Category:** support
**Tags:** asciidoc
**Created:** [July 12, 2019, 8:54pm UTC](https://discourse.gohugo.io/t/toc-with-anchors-in-posts/19627 "2019-07-12T20:54:06Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![TotallyInformation](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/totallyinformation/32/5668_2.png) [@TotallyInformation](https://discourse.gohugo.io/u/TotallyInformation)
#### Post date: [July 22, 2019, 10:26pm UTC](https://discourse.gohugo.io/t/toc-with-anchors-in-posts/19627/12 "2019-07-22T22:26:25Z")

</div>

OK, found it:

> [@Adding anchor next to headers](https://discourse.gohugo.io/t/adding-anchor-next-to-headers/1726/10):
>
> Slight variation to make it closer to a GitHub style: .hanchor { font-size: 50%; visibility: hidden} h2:hover a { visibility: visible} function addAnchor(element) { element.insertAdjacentHTML('beforeend', `\<a href="#${element.id}" class="hanchor" ariaLabel="Anchor"\>link\</a\>` ) } document.addEventListener('DOMContentLoaded', function () { // Add anchor links to all headings var headers = document.querySelectorAll('article h1[id], article h2[id], article h3[id], article h4[id]') if…

---

_[View the full topic](https://discourse.gohugo.io/t/toc-with-anchors-in-posts/19627)._
