Web Development
How to create web anchors in Markdown
November 24, 2020
After writing my very first long technical blog, I showed it to my twin sister who advised that it would be easier to navigate if I added web anchors.
It was at this point that I realize I had never implemented web anchors before--not in HTML let alone in Markdown.
This is how you do it. In your table of contents, use the following code:
## [First Section](#firstAnchor)
Use this code for where you want your table of contents to link to:
## <a name='firstAnchor'>First Section</a>
Here are a few things to keep in mind:
- My table of contents and section titles use the
H2
header. You may have different formatting on your blog. - The class name can be anything you want it to be. Just make sure that they match up.
- I use HTML for my second code block. Markdown supports HTML so this formatting will work for you!