Github Markdown Same Page Link

GithubHyperlinkMarkdownAnchor

Github Problem Overview


Let's say I have two points within the same git hub wiki page, which for this we'll call place 1 and place 2.

##Title

###Place 1

Hello, this is some text to fill in this, [here](place2), is a link to the second place.

###Place 2

Place one has the fun times of linking here, but I can also link back [here](place1).

An alternative is a ToC.

##Title
[ToC]
###Place 1
###Place 2

Is there any way to do this? Note - seen this so I'll assume it's on topic. Also, that deals with going between files, this one deals with going between the same file.

Github Solutions


Solution 1 - Github

This works on Github:

## Title

### Place 1

Hello, this is some text to fill in this, [here](#place-2), is a link to the second place.

### Place 2

Place one has the fun times of linking here, but I can also link back [here](#place-1).

### Place's 3: other example

Place one has the fun times of linking here, but I can also link back [here](#places-3-other-example).

Summary of the conversion rules:

  • punctuation marks will be dropped
  • leading white spaces will be dropped
  • upper case will be converted to lower
  • spaces between letters will be converted to -

A good example document with plenty of links and formatting is LivingSocial API Design Guide

Solution 2 - Github

It's also possible to create named custom anchors, if for example you have a bunch of (sub-)headings with the same name. To do this with a header insert an HTML tag:

<h4 id="login-optional-fields">
Optional Fields
</h4>

Then link to it by the ID attribute:

[see above](#login-optional-fields)

Also adding an anchor tag directly to the document works as well:

<a id="my-anchor"></a>

Solution 3 - Github

> Copied from GitHub Gist - the original post located here

To create anchor links that jump down to different sections of a README (as in an interactive table of contents), first create a heading:

#Real Cool Heading

The anchor link for that heading is the lowercase heading name with dashes where there are spaces. You can always get the anchor name by visiting the README on Github.com and clicking on the anchor that appears when you hover to the left of the heading. Copy everything starting at the #:

#real-cool-heading

Wherever you want to link to your Real Cool Heading section, put your desired text in brackets, followed by the anchor link in parentheses:

[Go to Real Cool Heading section](#real-cool-heading)

Solution 4 - Github

example 1:

##Title

###Place 1<span id="place1">HelloWorld</span>

Hello, this is some text to fill in this, [here](#place2), is a link to the second place.

###Place 2<span id="place2">HelloWorld</span>

Place one has the fun times of linking here, but I can also link back [here](#place1).

Here is a version that could jump from place1 to place2 and jump from place2 to place1

##Title

###[Place 1](#Place-2)<span id="place1">HelloWorld</span>

Hello, this is some text to fill in this, [here](#place2), is a link to the second 
place.

###Place 2(#Place-1)<span id="place2">HelloWorld</span>

Place one has the fun times of linking here, but I can also link back [here](#place1).

Solution 5 - Github

Unfortunately, it appears that GitHub wiki strips all of the "id=.." tags from custom HTML that you add to a wiki page, so the only working anchors within a page are the headings.

Solution 6 - Github

Accepted answer didnt work for me coz my heading was also a link :

Before (Didnt work):

Table of contents 

 1. [Header Name](#header-name)


### [Header Name](https://google.com)

After (worked for me) :

Table of contents 

 1. [Header Name](#header-name)


### Header Name

https://google.com

This is when u dont want to have html and want to work with accepted solution with some tradeoffs in readme.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlexander CraggsView Question on Stackoverflow
Solution 1 - GithubFelixEnescuView Answer on Stackoverflow
Solution 2 - GithubbcattleView Answer on Stackoverflow
Solution 3 - GithubEladTalView Answer on Stackoverflow
Solution 4 - GithubJ.ZhaoView Answer on Stackoverflow
Solution 5 - GithubcpurdyView Answer on Stackoverflow
Solution 6 - GithubJay TeliView Answer on Stackoverflow