简体   繁体   中英

Github Markdown Same Page Link

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

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

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

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>

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)

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

不幸的是,GitHub wiki 似乎从您添加到 wiki 页面的自定义 HTML 中删除了所有“id=..”标签,因此页面中唯一可用的锚点是标题。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM