CSS not loading for GitHub pages

后端 未结 2 1503
梦如初夏
梦如初夏 2021-01-19 16:03

I have a site published with GitHub pages:

https://safelyswift.github.io/Swizzle/

I want to use docs/css/style.css in my index.html

相关标签:
2条回答
  • 2021-01-19 16:31

    Try: <link rel="stylesheet" href="css/style.css">

    0 讨论(0)
  • 2021-01-19 16:49

    You should link to css/style.css, which is short of https://safelyswift.github.io/Swizzle/css/style.css because the root directory of your GitHub Page is /docs.

    The reason "https://github.com/SafelySwift/Swizzle/blob/master/docs/css/style.css" not work is because this link actually goes to the GitHub code preview page. It's not a valid CSS file but an HTML page with lots of GitHub functions(preview, commit log, history, etc.) But "https://safelyswift.github.io/Swizzle/css/style.css" is served by GitHub Page, so this link contains only pure CSS file which is valid.

    To see the difference between these files. Just navigate these link with your browser, and right-click your page to see the source code. You can see what your browser sees there.

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