Gitlab, in markdown, how can I use anchors other then headers?

Viewed 752

I would like to use links in markdown that points to an element in a list or a table (or text) and not specially a header.

The only solution I found for markdown is to use HTML anchors :

This is a list of actions:
- <a id="action-one">action one</a>`: blablanla
- <a id="action-two">action two</a>`: patata

Later, in text, [action one](#action-one) is mandatory...

This works well in VScode (for example) but not in Gitlab.

FYI :

Any idea or solution is welcome. Thanks.

1 Answers

There are two things to know :

  1. Writing the anchor tag

Example : [Text that will be a link](#this-is-my-tag)

  1. Knowing which tag to use

Which tag should you put ? Well gitlab generates them automatically. As you know, your markdown is translated to html to be displayed on the repo page. To know which tag you should use, just check the readme with the devtools. Inspect the html code. Here is an example of a heading in my repo, on gitlab :

<a aria-hidden="true" href="#2a-scrap-tarif" class="anchor" id="user-content-2a-scrap-tarif"></a>

We see the href tag is #2a-scrap-tarif.

So to go there, I will just write [Here is my link](#2a-scrap-tarif)

Related