GitHub Markdown – Relative Link to Repo’s Root

githubmarkdownreadme

I need to have a relative link to root of my repo from markdown file

(I need it working for any forks)

So it looks like the only way it's to provide a link to some file in the root:

the [Root](/README.md)

or

the [Root](../README.md)

(if it's located at /doc/README.md for instance)

At the same time I can refer to any folder without referring to a file

the [Doc](/doc)

But if I try to put a link to the root folder:

the [real root](/)

the [real root](../)

I'll have a link such

https://github.com/UserName/RepoName/blob/master

which unlike the

https://github.com/UserName/RepoName/blob/master/doc

refers to 404

So if I don't want to refer to README.md in the root (I could havn't it at all)

Is there any way to have such a link?

Best Answer

After some research I've found this solution:

[the real relative root of any fork](/../../)

It always points to the default branch. For me it's Ok, so it's up to you

PS

With such a trick you can also access the following abilities:

[test](/../../tree/test) - link to another branch

[doc/readme.md](/../../edit/master/doc/readme.md) - open in editor

[doc/readme.md](/../../delete/master/doc/readme.md) - ask to delete file

[doc/readme.md](/../../commits/master/doc/readme.md) - history

[doc/readme.md](/../../blame/master/doc/readme.md) - blame mode

[doc/readme.md](/../../raw/master/doc/readme.md) - raw mode (will redirect)

[doc/](/../../new/master/doc/) - ask to create new file

[doc/](/../../upload/master/doc/) - ask to upload file

[find](/../../find/test) - find file

Related Question