Jekyll Blog在github页面中没有正确设置样式

时间:2015-07-28 13:00:29

标签: css github jekyll github-pages

我已经安装了jekyll以及在本地创建了一个帖子。我把我的提交推到了主分支&创建了一个没有提交的孤儿分支gh-pages。

在我的float: 32.4246 integral: 144532 中,基本网址代码是这样的, _config.yml博客是我的回购。

我将baseurl: "https://githubusername.github.io/blog"添加到default.html。 如果我加载此链接,https://githubusername.github.io/blog该网站无法正常呈现。See Image

可能是我的问题/错误?提前谢谢。

1 个答案:

答案 0 :(得分:4)

  1. Set your baseurl to just: /blog.

    • Baseurl is the part after the url (something.github.io), before the page-path, read this for further clarification.
  2. Why is your HTML code for stylesheets linking to a .scss file? That's SCSS/SASS, which needs to be processed by Jekyll's SASS converter (or your own converter, into a nice CSS file). HTML only accepts CSS stylesheets.

    • To do so make sure your SCSS file has a YAML frontmatter, that is 3 dashes (-) then 2 newlines, followed by another 3 dashes.
  3. Change your stylesheet link in default.html to this:

    <link rel="stylesheet" href="{{ site.baseurl }}/css/main.css">

    • Notice the .css instead of .scss, and also the additional site.baseurl

Alternatively, should you decide not to deal with all the site.baseurl stuff, you can just have site.baseurl remain a value of "https://githubusername.github.io/blog" and then just modify the style sheet link to href= blog/css/main.css (after converting the .scss file) but this defeats the purpose of a baseurl. Also, if you decide you don't want it to be in blog in the future you'll have to make a ton of link edits.