loading...

Named Anchors & Markdown

stephencweiss profile image Stephen Charles Weiss Originally published at stephencharlesweiss.com on ・2 min read

When writing longer files in Markdown, I find it useful to create links within the document to help readers navigate.

This cross referencing makes jumping around the document even simpler.1 (Note: this 1 is an example of the link I'm talking about!)

For example:

### <a id="my-header"></a> Header

…
And then later, I want to go to [Header](#my-header), you create a link, just like any other.

The reason we have to add the anchor tag to the Header is that the Markdown spec doesn’t automatically do it.

Fortunately, many Markdown resolvers do. Dev.to, Gitlab, VSCode, Remark, etc. all do!

If you’re using one of these to convert the Markdown to HTML, things are even simpler2 :

### My Stupendous Header

…
And then later, I want to go to the [header](#my-stupendous-header), you create a link, just like any other.

Footnotes

Discussion

pic
Editor guide
Collapse
luisjosesanchez profile image
Luis José Sánchez

Thanks a lot! Works for me :-)

Collapse
murrayvarey profile image
MurrayVarey

Thanks Stephen! This really helped me. (A bit after the event, I know ... )