GitHub pages and relative paths

前端 未结 7 1149
梦如初夏
梦如初夏 2020-11-30 22:40

I have created a gh-pages branch for a project that I am working on at GitHub.

I use Sublime text to author the website locally and my problem is that w

相关标签:
7条回答
  • 2020-11-30 23:45

    This should not be an issue anymore in Dec. 2016, 3 and an half years later.
    See "Relative links for GitHub pages", published by Ben Balter:

    You've been able to use relative links when authoring Markdown on GitHub.com for a while.

    (that is from January 2013)

    Now, those links will continue to work when published via GitHub Pages.

    If you have a Markdown file in your repository at docs/page.md, and you want to link from that file to docs/another-page.md, you can do so with the following markup:

    [a relative link](another-page.md)
    

    When you view the source file on GitHub.com, the relative link will continue to work, as it has before, but now, when you publish that file using GitHub Pages, the link will be silently translated to docs/another-page.html to match the target page's published URL.

    Under the hood, we're using the open source Jekyll Relative Links plugin, which is activated by default for all builds.

    Relative links on GitHub Pages also take into account custom permalinks (e.g., permalink: /docs/page/) in a file's YAML front matter, as well as prepend project pages' base URL as appropriate, ensuring links continue to work in any context.

    And don't forget that since August 2016, you can publish your pages right from the master branch (not always the gh-pages branch)

    And since Dec. 2016, you don't even need Jekyll or index.md. Simple markdown files are enough.

    0 讨论(0)
提交回复
热议问题