不显示本地观察​​到的 Github 格式的博文

Not displaying blog posts formatted in Github as observed locally

如果我的博客在本地构建良好但在 GitHub 中,可能的原因是什么?一旦进入 GitHub 导航栏不显示也不应用 post 样式;有趣的是,这种奇怪的行为只影响 post 个页面。

我的博客已设置 here and here 是其存储库。 每当点击博客时,就会出现奇怪的行为 post。

你需要确保你有这个:

_config.yml:

highlighter: rouge
markdown: kramdown
kramdown:
  input: GFM

gems:
  - jekyll-paginate
  # other gems

Gemfile:

source 'https://rubygems.org'

gem 'github-pages'
gem 'jekyll-paginate'
# other gems

然后,在您的项目位置打开终端,然后 运行:

bundle update => 将更新您所有的宝石

bundle install => 将生成一个新的 Gemfile.lock 包括所有 gem 及其依赖项

bundle exec jekyll serve => 将通过 Bundler

为 Jekyll 提供服务

为什么?,你可能会问。 Jekyll 有一个新版本 3,并且 GitHub Pages followed the upgrade. The default markdown in now kramdown and the default highlighter is now rouge. Any doubts, check it here.


另外:

您的博文没有在 index.html 标题中找到您的样式表的链接:

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />    
<link rel="stylesheet" href="/css/bootstrap.min.css" />
<link rel="stylesheet" href="/css/main.css" />
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" />
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" />
<link rel="stylesheet" href="/css/index.css" />

你的 includes 可能有问题。

我们称它为 Jekyll 3 shake

您的博客在本地构建正常,因为您仍在使用 github-pages version 40jekyll version 2.4.0

bundle update
bundle exec jekyll build

它会在帖子上中断。

来自您的工作流程post -> post layout -> base layout that includes head.html

jekyll 2.4.0 中:从 head 你看到 page.layout = base 然后你看到 base layout front matter 变量。 在 jekyll 3.0.3 中:从 head 你看到 page.layout = post 然后你 can't 看到 base layout front matter变量。

想法可以是将 base 的 front matter 变量移动到 _config.yml :

common-css:
  - "/css/bootstrap.min.css"
  - "/css/main.css"
common-ext-css:
  - "//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"
...

并在 _includes/head.html

中获取这些变量
{% if site.common-ext-css %}
  {% for css in site.common-ext-css %}
    <link rel="stylesheet" href="{{ css }}" />
  {% endfor %}
{% endif %}

js 文件也一样。

注意:升级到 Jekyll 3.x 意味着您添加

gems: [jekyll-paginate]

到您的 _config.yml 文件。