Mark Pinho
Mark Pinho

Reputation: 125

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

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.

Upvotes: 9

Views: 7285

Answers (2)

### 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 -.

Upvotes: 0

Ekure Edem
Ekure Edem

Reputation: 330

You add an anchor to the section i.e

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

then link it using

[Section 1](#section-1)

Upvotes: 7

Related Questions