Jekyll github 页面站点忽略 .css

Jekyll github pages site ignoring .css

这在某一时刻奏效了。但是,我将项目保留在我认为可以正常工作的状态,然后回来发现格式全部损坏。回购可用 here and the site hosted here.

我检查了我的 _layouts/ 文件夹,它的 / 似乎根据答案 here.

正确设置

同样,我设置了我的基础 URL,因为这是根据

的项目页面

当我推送 RMD 文件时可能出了点问题,但是我试图回退并推送它作为 repo 的版本,但我没有看到任何变化(也许我做得不好,我是 github 的新手,也是 git 的新手)。

我怎样才能恢复格式?原始结构是使用 jekyll and ghpages.

上的本教程制作的

最终解决方案:

在检查和测试了 LarsW 和 David_Jacquel 的答案后,最终修复如下:

  1. _config.yml - 包括 baseurl: /Pokemon_FieldStudies
  2. default.html - 包括 <link rel="stylesheet" type="text/css" href="{{ site.baseurl }}/css/main.css">

你的 main.css 是空白的,为什么网页没有样式。

将此代码放入您的 main.css 并希望它能正常工作。

body {
    margin: 60px auto;
    width: 70%;
}
nav ul, footer ul {
    font-family:'Helvetica', 'Arial', 'Sans-Serif';
    padding: 0px;
    list-style: none;
    font-weight: bold;
}
nav ul li, footer ul li {
    display: inline;
    margin-right: 20px;
}
a {
    text-decoration: none;
    color: #999;
}
a:hover {
    text-decoration: underline;
}
h1 {
    font-size: 3em;
    font-family:'Helvetica', 'Arial', 'Sans-Serif';
}
p {
    font-size: 1.5em;
    line-height: 1.4em;
    color: #333;
}
footer {
    border-top: 1px solid #d5d5d5;
    font-size: .8em;
}

ul.posts { 
    margin: 20px auto 40px; 
    font-size: 1.5em;
}

ul.posts li {
    list-style: none;
}

link 是错误的。 /css/main.css 中的第一个 / 使其转到根文件夹,即域 (http://davergp.github.io/) and not the site (http://davergp.github.io/Pokemon_FieldStudies/)。只需将其更改为 /Pokemon_FieldStudies/css/main.csscss/main.css.

检查 .gitignore 文件是否排除了 CSS 文件未推送到远程仓库。

_config.yml中设置baseurl: /Pokemon_FieldStudies

像这样给你打电话 css : <link rel="stylesheet" type="text/css" href="{{ baseurl }}/css/main.css">