GitHub relative link in Markdown file

Update 30th, January 2013, 16 months later:

GitHub Blog Post Relative links in markup files:

Starting today, GitHub supports relative links in markup files.
Now you can link directly between different documentation files, whether you view the documentation on GitHub itself, or locally, using a different markup renderer.

You want examples of link definitions and how they work? Here’s some Markdown for you.
Instead of an absolute link:

[a link](

…you can use a relative link:

[a relative link](
[a relative link](path%20with%20spaces/

and we’ll make sure it gets linked to user/repo/blob/branch/

If you were using a workaround like [a workaround link](repo/blob/master/, you’ll have to update your documentation to use the new syntax.

This also means your documentation can now easily stand on its own, without always pointing to GitHub.

Marcono1234 adds in the comments

Also useful: When the link starts with a /, it is relative to the root of the repository (regardless of whether the markdown file is nested in subdirectories)

Update December 20th, 2011:

The GitHub markup issue 84 is currently closed by technoweenie, with the comment:

We tried adding a <base> tag for this, but it causes problems with other relative links on the site.

October 12th, 2011:

If you look at the raw source of the of Markdown itself(!), relative paths don’t seem to be supported.
You will find references like:


As noted in InvisibleWolf’s answer, if the target link is a directory and it has space, then you need to use %20 for each space.

Leave a Comment