Oleg Pro Oleg Pro - 1 month ago 9
Markdown Question

Relative Link to Repo's Root from Markdown file

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?


Answer

after some reseach I've found such solution:

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

it always points to the default brunch. 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 brunch

[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) - row 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