Jekyll 远程主题在本地不起作用

Jekyll remote theme doesn't work locally

摘要

我想达到的目标

我正在尝试使用 Jekyll 和最小错误在 GitHub 页面中构建博客。在推送更改之前,我想检查页面是否一切正常。

环境

我做了什么

  1. bundle exec jekyll new . --force
  2. 安装主题 GitHub Pages Method
  3. bundle exec jekyll serve

实际发生了什么

我有一个与 libcurl.dll 有关的错误。这是 Powershell 上的消息。

Dependency Error: Yikes! It looks like you don't have jekyll-remote-theme or o ne of its dependencies installed. In order to use Jekyll as currently configured , you'll need to install this gem. The full error message from Ruby is: 'Could n ot open library 'libcurl': (illegal characters) . Could not open libr ary 'libcurl.dll': (illegal characters) . Could not open library 'lib curl.so.4': (illegal characters) . Could not open library 'libcurl.so .4.dll': (illegal characters) ' If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!

我按照 GitHub Pages Dependencies Missing · Issue #17 · benbalter/jekyll-remote-theme 中的说明进行操作,问题已解决。

然后 bundle exec jekyll serve 出现了另一个错误。本地创建的页面是空白的。 http://127.0.0.1:4000/ 什么都不显示。

PS E:\workspace\mysite\dixhom.github.io> bundle exec jekyll serve
Configuration file: E:/workspace/mysite/dixhom.github.io/_config.yml
            Source: E:/workspace/mysite/dixhom.github.io
       Destination: E:/workspace/mysite/dixhom.github.io/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
      Remote Theme: Using theme mmistakes/minimal-mistakes
     Build Warning: Layout 'single' requested in _posts/2018-02-06-welcome-to-jekyll.markdown does not exist.
     Build Warning: Layout 'default' requested in 404.html does not exist.
     Build Warning: Layout 'page' requested in about.md.bak does not exist.
     Build Warning: Layout 'home' requested in index.html does not exist.
     Build Warning: Layout 'home' requested in index.md.bak does not exist.
                    done in 5.423 seconds.
 Auto-regeneration: enabled for 'E:/workspace/mysite/dixhom.github.io'
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.

看起来 jekyll 无法读取布局文件。此外,_layouts 目录不在我bundle exec jekyll new 所在的目录中。但默认情况下, so it's normal not to see the directory. So I just copied _layouts from minimal-mistakes GitHub repo 到本地目录作为解决方法。

然后,出现了另一个错误。

PS E:\workspace\mysite\dixhom.github.io> bundle exec jekyll serve
Configuration file: E:/workspace/mysite/dixhom.github.io/_config.yml
            Source: E:/workspace/mysite/dixhom.github.io
       Destination: E:/workspace/mysite/dixhom.github.io/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
      Remote Theme: Using theme mmistakes/minimal-mistakes
  Liquid Exception: Could not locate the included file 'sidebar.html' in any of ["E:/workspace/mysite/dixhom.github.io/_
includes"]. Ensure it exists in one of those directories and, if it is a symlink, does not point outside your site sourc
e. in /_layouts/single.html
jekyll 3.6.2 | Error:  Could not locate the included file 'sidebar.html' in any of ["E:/workspace/mysite/dixhom.github.i
o/_includes"]. Ensure it exists in one of those directories and, if it is a symlink, does not point outside your site so
urce.

我本可以用同样的方式复制 _includes,但我认为问题的核心在于 jekyll 未能从 jekyll 读取必要的文件,例如 GitHub回购

奇怪的是,当我将本地更改推送到 GitHub 时,GitHub 页面显示 正确呈现的页面,如下所示。

顺便说一下,repo 是 https://github.com/Dixhom/dixhom.github.io/tree/7132905f5515345eb78cd71bdad168a15f906a1c

我怀疑 jekyll-remote-theme 在本地环境中不起作用,所以我用谷歌搜索 "jekyll remote theme serve" 没有帮助。

像 "remote theme Build Warning: Layout does not exist." 这样的谷歌搜索关键字没有多大帮助。

我该如何解决这个问题?

aaaah 我也很反对这个。我 运行 bundle exec jekyll serve --verbose 并看到 jekyll-remote-theme 根本没有被初始化(每个插件记录一个 Requiring: jekyll-<thing> 行)。然后我注意到 Gemfile 中的这个块:

# If you have any plugins, put them here!
group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.6"
end

我将 "gem jekyll-remote-theme" 添加到该插件块并修复了它 – 哦!

jekyll 更新日志中有一些关于这个 Gemfile 组的注释,但我没有发现任何注释对解释这里发生的事情有很大帮助。

希望对您有所帮助!