248

GitHub wikis allow you to link to other pages in the wiki like so:

[[Wiki Page Name]]

However, I want to display different text than the wiki page name when making the link. Is there a way to do this? Am I linking to wiki pages all wrong?

1
  • 2
    Although markdown is not a programming language, we have plenty of questions tagged XML (another markup language) on StackOverflow. I didn't check but I bet there are some on data exchange formats like JSON. Why not allow this question? Commented May 11, 2022 at 0:18

5 Answers 5

341

Using the Markdown link syntax

[Link Text](WikiPage)

seems to work in the edit preview but not on the actual wiki page. At least for me the generated link is WikiPage instead of wiki/WikiPage and I get the famous GitHub 404.

However the MediaWiki syntax

[[Link Text|WikiPage]]

works for me, even for Markdown wiki pages.

9
  • 1
    This does seem to work consistently, even though it's not in Github's markup documentation. See my comment on @cbley's answer for why his solution seems to work sometimes but not others.
    – mltsy
    Commented Jul 18, 2012 at 17:19
  • 6
    Further, if the link text and Wiki page are the same, you can simply use: [[My Wonderful Wiki Page]]. This will link to wiki/My-Wonderful-Wiki-Page.
    – Jimothy
    Commented Apr 4, 2013 at 12:44
  • 7
    Yes, [[Link Text|WikiPage]] works for me. Pleas edit your answer Commented Apr 15, 2013 at 12:31
  • 2
    Here is a reference to Add links to wikis
    – Ricardo
    Commented Nov 13, 2014 at 21:27
  • 3
    Note that, as of March, 2019, while MediaWiki syntax works for links with plain text as the link text, it breaks when asked to parse link text with any formatting, whether Markdown or MediaWiki syntax. For example, ``` [[Description of foo|Foo]] ``` will render the (code-formatted) source markup, not the intended link. If anyone knows a way around this, please let me know. Commented Mar 2, 2019 at 6:19
103

GitHub by default uses Markdown syntax for the wikis so you can just use the page's path:

[Arbitrary Link Text](Wiki-Page-Name)

Check out Markdown and this blog post for more information about their wikis and the other markup syntaxes they support.

This solution has issues when you're on the home page because it creates relative URLs. Check out Sven's answer, below.

10
  • 31
    @Sven's answer is correct, this answer is wrong.
    – Jon Cram
    Commented Jul 11, 2012 at 10:56
  • 26
    This creates a relative url link, so if you happen to be in the same directory as the page you're trying to link to it works, otherwise, it does not. Specifically, if you'er on the Home page (http://.../project_name/wiki), this won't work, because all other pages are in the wiki directory, whereas the homepage isn't.
    – mltsy
    Commented Jul 18, 2012 at 17:17
  • 4
    -1 since it breaks; Needs to be updated to include last comment on this thread and I'll change to +1. Commented Jan 21, 2013 at 2:37
  • 10
    Yes, [[Link Text|WikiPage]] works for me. Pleas add to your answer Commented Apr 15, 2013 at 12:34
  • 7
    As of May 2014, this appears to have been fixed on GitHub. This answer now works on all pages. However, the preview is still broken.
    – drhagen
    Commented May 9, 2014 at 21:20
41

The internal-ref part is relative to your project. For wiki pages use:

[Page Name](wiki/Page-Name)

In the preview the link will be broken but when the page is saved it will work.

4
  • 2
    Works but Sven's answer works better. Commented Feb 28, 2016 at 18:35
  • 5
    There is a problem with this when using inside a custom sidebar, if you navigate to one of your link, like wiki/Page-Name, then in the wiki/Page-Name page's sidebar, links are broken having a double wiki element like wiki/wiki/Page-Name.
    – Matt
    Commented Jan 18, 2017 at 18:36
  • This does not work within <html>...</html> tags whereas [[Link text|Page Name]] does.
    – Paul Wintz
    Commented Dec 2, 2022 at 22:44
  • When I include "wiki/", the resulting link includes "wiki/wiki/Page-Name".
    – Paul Wintz
    Commented Dec 2, 2022 at 22:48
2
  • The most common use [Link Text](WikiPageURL)
  • The second way: [[Link Text|WikiPageURL]]
  • The third way, if you do not want to repeat and need to use the hyperlink several times: [Link Text] and at the end of the page use once [Link Text]:WikiPageURL
-8

Check the wiki editor's help. It tells you:

To create a reference link, use two sets of square brackets. [my internal link][internal-ref] will link to the internal reference internal-ref.

2
  • 2
    I also saw that, but it does not work, because - as cbley mentioned - Markdown requires round brackets around internal-ref. I wonder why the help contains wrong information. Commented Dec 8, 2011 at 0:35
  • 2
    The wiki's help editor does say that, but "internal reference" in this case refers to an in-page Markdown reference, not another page in the same wiki. See the Markdown link syntax for more info.
    – Calrion
    Commented Jul 12, 2012 at 2:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.