markdown | gatsby

Markdown - Link within document

This is a short article on how to link within the document in a markdown (.md) file.

Abhith Rajan
Abhith RajanNovember 06, 2017 · 2 min read · Last Updated:

I use markdown as the writing language for my blog posts on this website. It is clean and minimal so I prefer it over HTML.

Today I updated some content in one of my blog posts, Xamarin development - problems and solutions and in which, there is a summary of issues listed on the top and the solutions for each of them explained below one by one and there wasn’t any link between the list items and the explanations.

So for better usability, I had to link them, I know how to do it in HTML and now I learned how to do it on Markdown.

To create the link,

[Link text](#some-id)

And add anchor point the target area by,

# <a name="some-id"></a> DETAIL SECTION

Notice the usage of ”some-id” in both. You can replace ”some-id” with any proper text.

As you can see, we are adding an anchor tag (HTML element) to the Markdown to make it work. Having HTML in markdown file is not that nice and some linters will complain about the same, this as a dirty hack.

Update 1 - 2nd May 2019

If you are using some kind of markdown transformer, there might be an option to make the header links automatically. Like gatsby-remark-autolink-headers in case of Gatsby.

This page is open source. Noticed a typo? Or something unclear?
Improve this page on GitHub


Abhith Rajan

Written byAbhith Rajan
Abhith Rajan is a software engineer by day and a full-stack developer by night. He's coding for almost a decade now. He codes 🧑‍💻, write ✍️, learn 📖 and advocate 👍.
Connect

Is this page helpful?

Related ArticlesView All

Related VideosView All

GatsbyJS & Analytics: How to Add Google Analytics 4.0 To a Gatsby Site Using Gtag

Related Tools & ServicesView All

tabletomarkdown.com

Table to Markdown

Table to Markdown is a simple Markdown table generator that converts tables from spreadsheet applications and websites into well-formatted Markdown tables.