从Markdown文件相对链接到Repo的根 [英] Relative Link to Repo's Root from Markdown file
问题描述
我需要一个相对链接到我的回购从降价文件
(我需要它适用于任何分支)
因此它看起来像是在根中为某个文件提供链接的唯一方式:
[Root](/ README.md)
或
< (如果它位于/ doc / c中),那么[root](../ README.md)
与此同时,我可以在不引用文件的情况下引用任何文件夹
[Doc](/ doc)
但是如果我尝试将一个链接放到根文件夹中:
[实根](/)
[real root](../)
我会有一个链接,例如
https://github.com/UserName/RepoName/ blob / master
不同于
https://github.com/UserName/RepoName/ blob / master / doc
指的是404 不想在根目录中引用README.md(我根本就没有它)
有什么办法可以拥有这样的链接吗?
经过一番研究,我发现了这样的解决方案:
[任何fork的真实相对根](/../../)
它总是指向默认分支。对我来说它是好的,所以这取决于你
PS
用这样的技巧你也可以访问以下功能:
[test](/../../ tree / test)
- 链接到另一个分支
[doc / readme.md](/../../ edit / master / doc / readme.md)
- 在编辑器中打开
$ {code> [doc / readme.md](/../../ delete / master / doc / readme.md) - 请求删除文件
[doc / readme.md](/../。 ./commits/master/doc/readme.md)
- history
[doc / readme.md]( /../../ blame / master / doc / readme.md) - 责怪模式
- 要求创建新文件
[doc /readme.md](/../../ raw / master / doc / readme.md)
- 行模式(将重定向)
<
$> [code>] [doc /](/../../ new / master / doc /)
[doc /](/../../ upload / master / doc /)
- 请求上传文件
[find](/../../ find / test)
- 查找文件
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?
after some research I've found such 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)
- 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
这篇关于从Markdown文件相对链接到Repo的根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!