How do you create a link to a specified section of your readme.md file?

5.7k views Asked by At

I am practicing readme files and I had a question about linking. Is there a way to link to a specific section of a readme? For example, I want to create a table of contents with links to the specific sections of my readme.md file.

# Title
## Sub Title
Brief description of project.

### Table of Content
* [Section 1](#section1)
* [Section 2](#section2)
* [Section 3](#section3)

# Section 1
some text

# Section 2
some text

# Section 3
some text

From my understanding I thought this would work but the links do not bring me to the sections, when I click them it does nothing.

2

There are 2 answers

1
Ekure Edem On BEST ANSWER

You add an anchor to the section i.e

#<a name="section-1"></a> Section 1

then link it using

[Section 1](#section-1)
0
Walter Rauschenberger On
### Table of Content
* [Section 1](#section-1)
* [Section 2](#section-2)
* [Section 3](#section-3)

will do the job. Note that anything but a normal character, such like a space for instance, has to be replaced by a -.