简体   繁体   中英

How to get relative links in a README.md to work on a Github page?

I have a repo, where I use relative links in the main README.md. However, when I generate a Github page for the repo and use the README as the main index page, the links won't work. I suppose this is because I use relative links. Is there a way to make them work or do I need to replace all the links with absolute ones?

Oh, I see what you mean now. You're not linking to the README.md directly but to the index.html in the gh-pages branch of the project.

If you add this to the head section of the index.html in the gh-pages branch of that project your links will work:

<base href="http://www.github.com/alexvpopov/ruby-exercises/tree/master/">

(If this breaks the stylesheets and images on that page then you'll just want to edit each link directly in that file to use the absolute URL.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM