Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Markdown Anchor Link With Same Name But Different Sections

You can link to an anchor heading in markdown quite easily.
[link to anchor heading](#background)

Plenty of stackoverflow questions deal with it such as this one or this one.

But I cannot seem to find a way to link to anchors that share the same name but are in different sections.

So for example, I cannot link to the background section in a different section.
[link to database background](#database#background)

As opposed to say :
[link to front end background](#front-end#background)

This does not work either.
[link to database background](#database##background)

I would expect the markdown anchor link to follow the section path specified. Is this not possible? Or am I using the wrong syntax?

like image 739
Leo E Avatar asked Sep 14 '19 11:09

Leo E


People also ask

How do I link to a specific section in markdown?

Just follow the [text](#link) syntax and follow these guidelines: write the letters and numbers as they are. replace spaces with dashes - remove the rest of the characters.

How do you make an anchor in markdown?

Explicit anchors can be inserted anywhere in the document using <a name="tag"></a> or {#tag} . Implicit anchors are automatically created for each heading. For example ## Section 1 will have the anchor Section-1 .

How do you add internal links in readme?

To create a link between pages, type in the name of your link between brackets "[ ]". As you start typing, internal page link options will appear.


1 Answers

As stated in the Markdown Guide, some applications allow you to use HTML tags in Markdown-formatted text (e.g. GitHub). Check your Markdown application's documentation to be sure.

If HTML is allowed, you can use the following:

# Front end

- [Background](#front-end-background)

<h2 id="front-end-background">Background</h2>

# Database

- [Background](#database-background)

<h2 id="database-background">Background</h2>

In the example above, <h2> is the same as ##. It also works with other headings.

like image 72
Rafael Tavares Avatar answered Sep 28 '22 09:09

Rafael Tavares