09 links - practicalseries/GitHub-Wiki-Design-and-Implementation GitHub Wiki
Links are used to jump to a particular page or heading within a Wiki, they can also be used to navigate to other websites or to download files (just like links on any web page).
Markdown links can be direct (normal type) links or can be reference-style links. Reference style links do exactly the same as direct links but make the Markdown easier to read (but in turn are more complicated to implement).
This section concerns itself with direct links (these are by far the most widely used) section 9.7 covers reference-style links.
Direct links can do the following:
β | Link to an external web page (a web page that is not associated with a particular Wiki or repository) |
β | Link to another page in the same Wiki |
β | Link to headings on the current Wiki page |
β | Link to headings on a different Wiki page |
β | Link to a named element on the same Wiki page |
β | Link to a named element on a different Wiki page |
β | Download a file |
List 9.1 β Various types of links |
---|
All of these are covered in the next sections:
This is the easiest (and probably most common) type of link, there are different versions:
βΆ | A straight forward (direct) link to a URL: https://google.co.uk |
β· | A link to a URL using substitute text e.g. Google UK |
βΈ | A link to a URL using substitute text and with a tooltip box that explains the link when the mouse hovers over it: e.g. Google UK |
List 9.2 β Links to an external web page |
---|
Taking each in turn:
Letβs say we want to put a link to the Google UK website on a Wiki page, at its most basic it would look like this:
This is a link to https://google.co.uk.
The Markdown for this is very easy (in fact there is no Markdown), GitHub automatically detects URLs and converts them to a web link:
Markdown and GitHub output | |
---|---|
|
|
This is a link to https://google.co.uk.
|
This is a link to https://google.co.uk. |
This is a link to https://www.google.co.uk.
|
This is a link to https://www.google.co.uk. |
This is a link to www.google.co.uk.
|
This is a link to www.google.co.uk. |
Table 9.1 β Markdown for a basic link |
The equivalent HTML for the above is:
HTML and GitHub output | |
---|---|
|
|
This is a link to <a href="https://google.co.uk">
https://google.co.uk</a>
|
This is a link to https://google.co.uk |
This is a link to <a href="https://www.google.co.uk">
https://www.google.co.uk</a>
|
This is a link to https://www.google.co.uk |
This is a link to <a href="www.google.co.uk">
www.google.co.uk</a>
|
This is a link to www.google.co.uk |
Table 9.2 β HTML for a basic link |
GitHub will render anything that starts https://
, http://
or www.
as a link.
Note
GitHub does not check the format of the link beyond the starting characters, it would think www.google was a perfectly good link (even though the domain suffix is missing), it would also think https://π³π³π³π³ is a link despite the fact the characters in it are not valid for URLs.
Links are always displayed in blue rgb(009,105,218) #0969DA
and underlined.
Links are always the same size as body text and can be emphasised with bold or italic by putting the appropriate number of asterisks before and after them (see section 6.4 and section 6.5). For example:
Markdown, HTML equivalence and GitHub output |
---|
|
This is a link to **https://google.co.uk**.
|
|
This is a link to <strong><a href="https://www.google.co.uk">https://www.google.co.uk</a></strong>
|
|
This is a link to https://google.co.uk. |
Table 9.3 β A basic link in bold |
It is possible to use substitute text which is displayed in place of the URL. Things like:
βββThe PracticalSeries website can be accessed here.
The word here is displayed in place of the full URL, but clicking the word navigates to the URL: https://practicalseries.com.
The Markdown for this is in the form:
ββ |
The
The Markdown for the above is:
Markdown, HTML equivalence and GitHub output |
---|
|
The PracticalSeries website can be accessed [here](https://practicalseries.com).
|
|
The PracticalSeries website can be accessed <a href="https://practicalseries.com">
here</a>
|
|
The PracticalSeries website can be accessed here. |
Table 9.4 β A basic link with substitute text |
A tooltip is a small box that opens up to display some information about the link whenever the mouse hovers over the link:
Try it by hovering the mouse over the link below:
βββSearch engine Google.
The following figure shows the effect:
![]() |
Figure 9.2 β Link to a web page with substitute text and tooltip |
---|
The Markdown for this is in the form:
ββ |
The
The Markdown for the above figure is:
Markdown, HTML equivalence and GitHub output |
---|
|
Search engine [Google](https://Google.co.uk "Link to Google UK").
|
|
Search engine <a href="https://google.co.uk" title="Link to Google UK">Google</a>.
|
|
Search engine Google. |
Table 9.5 β A basic link with substitute text and tooltip |
Linking to pages in the same Wiki doesnβt require a full web address (URL), GitHub accepts relative addressesπ 1 (this is true for both Markdown and HTML).
Letβs say that a Wiki exists with three pages in a folder structure as follows:
![]() |
Figure 9.1 β Simple Wiki structure |
---|
Here there are three pages: Home.md
in the root directory, Page01.md
in folder 01_Page1
and Page02.md
in folder 02_Page2
. The .md
files are shown in red in the above figure.
All Wiki pages are .md
files and GitHub ignores the folder structure when navigating the Wiki folder structure for .md
(but only for .md
files, all other files must include the correct path to the file).
To link to any other page in the Wiki, all that is necessary is to include the filename, but not the extension in the link.
Thus if Page02.md
required a link to Page01.md
it would simply have the following Markdown:
Markdown, HTML equivalence and GitHub output |
---|
|
[Link to page 1](page01)
|
|
<a href="page01">Link to page 1</a>
|
|
Table 9.6 β Relative link to a page within the same Wiki |
Note
The important thing to remember is that the .md
extension must not be included in the relative link. Only use the filename that precedes the extension (it is not case sensitive).
All that is needed for a link to any other page in the Wiki is simply the filename of the page that is to be navigated to (always without the file extensionπ 2)
Links to other page in the Wiki can also have tooltips (in exactly the same way as links to an external page, see section 9.1.3 ), in this form:
ββ |
For example adding a tooltip to the previous example gives (to see the effect, hover the mouse over the link at the bottom):
Markdown, HTML equivalence and GitHub output |
---|
|
[Link to page 1](page01 "GO TO PAGE 1")
|
|
<a href="page01" title="GO TO PAGE 1">Link to page 1</a>
|
|
Table 9.7 β Relative link to a page within the same Wiki with tooltip |
The Markdown and HTML forms for linking to a Wiki page are:
ββ ββ |
The .md
file with the following changes:
βΆ |
Do not add the .md extension to the |
β· |
Any spaces within the |
βΈ | All uppercase letters are made lowercase (optional) |
List 9.3 β RRules for converting a page name to a link |
---|
For example, the page:
βββ
Would becomes the
βββ
Thus:
Markdown, HTML equivalence and GitHub output |
---|
|
[Section 8.2](08.02-block-quotes,-lists-and-alerts)
|
|
<a href="08.02-block-quotes,-lists-and-alerts">Section 8.2</a>
|
|
Note
While it is not necessary to change the name to all lowercase letters, it is best to do so, it gives consistency to the addressing.
GitHub can link to any Markdown heading on a page (the ones constructed with leading hashes, see section 6.10 ). In fact, GitHub highlights the links and allows them to be copied, these highlights are the small chains that appear when the mouse hovers over the link:
![]() |
Figure 9.3 β Heading link icon (highlighted) |
---|
To copy the link, right click and select
Clicking a link to a heading navigates up or down the page until the heading is at the top of the browser window.
Links to a heading on the same page are constructed in a similar way to the direct link using substitute text (see section 9.1.2) as follows:
ββ |
The
Note
Just inserting the hash and the #headingName directly in the Markdown (like the direct link of section 9.1.1) will not work.
The
βΆ |
There is only one hash `#` before the |
β· | All text is converted to lowercase |
βΈ | Spaces are converted to a single dash |
βΉ | If multiple consecutive spaces are present, they are converted to a single dash |
βΊ | Special space characters (see section 7.2) are ignored |
β» | Any HTML tags are ignored (tags and attributes between `<>`) |
βΌ | Any comments within the heading (text between ``) are ignored |
β½ | Numbers (0 to 9) are included |
βΎ | All non-alphanumeric characters are ignored |
List 9.4 β Rules for converting a heading |
---|
For example, on the Wiki page: 01 Introducing the GitHub Wiki there is a heading: 1.1. What are GitHub Wiki pages?.
The Markdown for the heading is this:
Markdown and GitHub output |
---|
|
## 1.1       <!-- H2 -->What are GitHub Wiki pages?
|
|
1.1βββββββWhat are GitHub Wiki pages? |
Now, this heading is a bit more complicated than the headings in section 6.10, but it works in the same way:
It starts as normal, with two hashes ##
, it is a level 2 heading. There is a chapter and section number separated by a full stop 1.1
.
Next, there are various special spacing characters:        
, these are used to space the title text from the heading number (see section 7.2). This is followed by a comment field <!-- H2 -->
that identifies the heading as a level 2 heading.
Finally, there is a question mark ?
at the end.
The link to this heading (from within the same page), would be:
Markdown, HTML equivalence and GitHub output |
---|
|
Link to [1.1 What are GitHub Wiki pages?](#11what-are-github-wiki-pages)
|
|
Link to <a href="#11what-are-github-wiki-pages">1.1 What are GitHub Wiki pages?</a>
|
|
Link to 1.1 What are GitHub Wiki pages? |
Table 9.8 β A link to a heading on the same page |
Letβs examine what has happened to the heading link:
It is preceded by a single hash #
, links only use one hash irrespective of the heading level.
The numbers 11
are the numbers in the heading 1.1
without the full stop (all non-alphanumeric characters are ignored).
All the special space characters  
&c. are ignored as is the comment field.
Thus, the numbers are immediately followed by the text of the heading in lowercase.
All the spaces between the words in the heading text are replaced with dashes -
.
Finally, the question mark at the end is missing (all non-alphanumeric characters are ignored).
So the Markdown (or HTML href
) for the link to the heading becomes:
Markdown |
---|
|
#11what-are-github-wiki-pages
|
Tooltips can also be applied to links to headings, this is exactly the same as shown in section 9.1.3 (hover the mouse over the link at the bottom to see the tooltip):
Markdown, HTML equivalence and GitHub output |
---|
|
Link to [1.1. What are GitHub Wiki pages?](#11what-are-github-wiki-pages "HEADING LINK")
|
|
Link to <a href="#11what-are-github-wiki-pages" title="HEADING LINK">1.1. What are GitHub Wiki pages?</a>
|
|
Link to 1.1. What are GitHub Wiki pages? |
Table 9.9 β A link to a heading on the same page with tooltips |
It is possible to link to any heading on a page within the same Wiki by adding the page name to the Markdown link. Links to a Hheading links to a point on a different page are constructed in a similar way to the heading link on a same page (see section 9.3), but also include the page name:
ββ |
The
The rules for the
Using the same example of section 9.3.2 where:
The Wiki page: 01 Introducing the GitHub Wiki has the heading: 1.1. What are GitHub Wiki pages?.
The Markdown for the heading is this:
Markdown and GitHub output |
---|
|
## 1.1       <!-- H2 -->What are GitHub Wiki pages?
|
This is the same as the heading in section 9.3.2.
The heading becomes the following when coverted to a link (again see section 9.3.2), the
Markdown |
---|
|
#11what-are-github-wiki-pages
|
The
Markdown |
---|
|
01-introducing-the-github-wiki
|
Thus the whole link become:
Markdown, HTML equivalence and GitHub output |
---|
|
[1.1.What are GitHub Wiki pages?](01-introducing-the-github-wiki#11what-are-github-wiki-pages)
|
|
<a href="01-introducing-the-github-wiki#11what-are-github-wiki-pages">1.1 What are GitHub Wiki pages?</a>
|
|
Table 9.10 β A link to a heading on a different page |
Footnotes:βββββ
Note
π 1βA relative address, or relative file path, identifies the location of a file relative to the location of the current page. It is common practice for websites to use relative addressing (see section 9.8 for details).β©
Note
π 2βThe relative link must not include the file extension, if the link in the example were page01.md
, the link would not work, GitHub will not find the file (I think it adds .md
to the filename and is now trying to find a file that ends .md.md
and it canβt).β©