Is there a way to create a URL anchor, <a>
, link from within a Markdown file, to another file within the same repository and branch (aka a link relative to the current branch)?
For example, in the master branch I have a README.md file, which I would like do something like:
# My Project
is really really cool. My Project has a subdir named myLib, see below.
## myLib documentation
see documentation [here](myLib/README.md)
This would allow me to link from one .md to another within the same branch and not have to worry about which branch I'm in (avoid having to do an absolute URL that includes the github.com branch name).
Here is a working example of what I mean:
- GOTO http://github.com/rynop/testRel, link does not work.
- GOTO http://github.com/rynop/testRel/blob/master/README.md, link works.
This is expected because at this point the starting URL is in the branch. Now how do I get it to pick up the current branch in the README.md at the root of the repository?
Update: I opened an issue against GitHub for this feature request.
Best Answer
Update 30th, January 2013, 16 months later:
GitHub Blog Post Relative links in markup files:
Marcono1234 adds in the comments
Update December 20th, 2011:
The GitHub markup issue 84 is currently closed by technoweenie, with the comment:
October 12th, 2011:
If you look at the raw source of the
README.md
of Markdown itself(!), relative paths don't seem to be supported.You will find references like:
As noted in InvisibleWolf's answer, if the target link is a directory and it has space, then you need to use
%20
for each space.