从 README 到 wiki 页面的 github 链接

如何在 github 中创建从 README.md 文件到 Wiki 页面的链接?每个示例似乎都显示了从一个 wiki 页面到另一个 wiki 页面的链接,或者从一个 README 文件到存储库中的另一个文件的链接。但是没有一个显示出它们之间的联系

36302 次浏览

You would have to use an absolute URL as opposed to a relative one.

For example:

[Sites Using React](https://github.com/facebook/react/wiki/Sites-Using-React)

I just came across this question and saw that this was impossible, but stubbornly kept trying anyway. Good news, because this actually can be done with relative links!

If you look at the documentation for relative links on GitHub, you can see that it supports ./ and ../ operands.

Given that your README is located at:

https://github.com/<user-name>/<repo-name>/blob/master/README.md

... and the wiki is located at:

https://github.com/<user-name>/<repo-name>/wiki

... that means you can just crawl back from the README to the wiki, like so:

[My Awesome Wiki](../../wiki)


Update: As some people have pointed out in the comments (thanks!), please be aware that these relative links will break on clones and forks, so be sure to weigh that into your decision!

Just to add on this one, if you want to refer to your repo file from inside wiki use ../../blob/master/. Combined with the answer from jmar777 this allows to completely integrate code and wiki and remove a need for bloated readme.md.

To make it work locally as well as your file structure would have to be

./Wiki/YourWikiRepo
./blob/master/YourCodeRepo

I found that I needed to crawl back 3 levels versus 2 levels as descreibed in jmar777's approach.

When I used

../../wiki

The link generated was https://github.com/<username>/blob/wiki

I needed to use:

../../../wiki

This generated https://github.com/<username>/wiki

I am using GitLab. My link to my Wiki page looks like this.

Checkout the [Wiki page](/%2E%2E/wikis/Welcome)

I tried the other recommendations that are posted here but it kept changing the URL with re-writes that broke the link.