Linking using relative path on Github README.md

Viewed 18204

I am trying to create links in my README.md that link to example code using a relative path, as opposed to the absolute path I am using now. For example, in the markdown file, if I use this:

[someLabel](https://github.com/username/repoName/somePathTo/myExampleCode)

It works no problem. But I would like to link it up using something like this:

[someLabel](username/repoName/somePathTo/myExampleCode)

This does not link up, as it gives me the ol' 404 not found error. Is there a way to link my examples on Github to my README using a relative path?

4 Answers

Here is a nuance. A leading slash changes the meaning of a link.

[someLabel](/repository/relative/link.txt)

[someLabel](directory/relative/link.txt)

I recently found out that the way you can use relative path in README.md is:

[file.pdf](/Documentation/file.pdf)

where Documentation is a folder at the root of my repository

Related