Impossible to create a relative link to root of project.
I can't find a way to link to the root of a repository. I am able to make links directly to the root README.md, but what I want is the default view when you visit the repository root, for example: https://github.com/github/markup is not the same as https://github.com/github/markup/blob/master/README.md
After inspecting the code generated by the markdown, I actually think this could be an issue with github routing. I think there is no reason for this to render a 404: https://github.com/github/markup/blob/master/
But this view to work: https://github.com/github/markup/
And these subfolder views to work: https://github.com/github/markup/tree/master/script https://github.com/github/markup/tree/master/lib
It's inconsistent and makes it impossible to create a portable README.md that links to the root of a repo.
======
How to reproduce:
Given the following tree structure:
├── dist
│ └── README.md
├── docs
│ └── README.md
└── README.md
With the following README.md files:
README.md:
# Test
*[Main](/)* | [Docs] | [Dist]
- FAIL [Main](./) `./ ==> /<user>/<repo>/blob/main (404)`
- FAIL [Main](/) `/ ==> /<user>/<repo>/blob/main (404)`
- FAIL [Main](/README.md) `../ ==> /<user>/<repo>/README.md (want /<user>/<repo>/)`
[Docs]: /docs
[Dist]: ./dist
dist/README.md:
# Test - Dist
[Main](..) | [Docs] | *[Dist]*
- FAIL [Main](..) `.. ==> /<user>/<repo>/blob/main (404)`
- FAIL [Main](/) `/ ==> /<user>/<repo>/blob/main (404)`
- FAIL [Main](../) `../ ==> /<user>/<repo>/blob/main (404)`
- FAIL [Main](/README.md) `../ ==> /<user>/<repo>/README.md (want /<user>/<repo>/)`
- FAIL [Main](../README.md) `../ ==> /<user>/<repo>/README.md (want /<user>/<repo>/)`
[Docs]: ../docs
[Dist]: ../dist
docs/README.md
# Test - Docs
[Main](/README.md) | *[Docs]* | [Dist]
[Docs]: ../docs
[Dist]: ../dist
Hello, For me, following works for me:
/../../
See Stackoverflow Question "Relative Link to Repo's Root from Markdown file"
While that is a workaround it means any time you move the location of the documentation file those links might need to change. While that might work in some cases, other times developers really do want the semantic from the root of the repo in their docs.
Perhaps something like if the first part of the link is a double slash // it should be from inferred as relative to the repo root, or maybe there's another convention available for this.
Really, all that seems to be necessary to solve this issue -- and prevent a 404 when referring to a branch's root using a relative path in a Markdown file -- would be to let the URL
https://github.com/<user>/<repo>/blob/<branch>
redirect to (or be replaced by)
https://github.com/<user>/<repo>/tree/<branch>
just like
https://github.com/<user>/<repo>/blob/<branch>/<folder>
is redirected to
https://github.com/<user>/<repo>/tree/<branch>/<folder>
I'm wondering whether the GitHub Markup project is the place to propose such a solution, though ...