【问题标题】:Jekyll remote theme doesn't work locallyJekyll 远程主题在本地不起作用
【发布时间】:2018-07-21 13:30:09
【问题描述】:

摘要

  • 我想在本地机器上看到 Jekyll 使用gem "jekyll-remote-theme" 制作的页面
  • 所以我跑了bundle exec jekyll serve
  • 但是出现了一个空白页

我想要实现的目标

  • 在本地机器上查看 Jekyll 使用 gem "jekyll-remote-theme" 创建的页面。

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

环境

  • Windows 8.1 64 位
  • ruby 2.4.3p205(2017-12-14 修订版 61247)[x64-mingw32]
  • 杰基尔 3.6.2

我做了什么

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

实际发生了什么

我遇到了与libcurl.dll 相关的错误。这是 Powershell 上的消息。

依赖错误:哎呀!看起来你没有 jekyll-remote-theme 或 o 没有安装它的依赖项。为了使用当前配置的 Jekyll ,您需要安装此 gem。来自 Ruby 的完整错误消息是:'Could n 未打开库“libcurl”:(非法字符)。无法打开库 ary 'libcurl.dll':(非法字符)。无法打开库'lib curl.so.4':(非法字符)。无法打开库'libcurl.so .4.dll':(非法字符)'如果遇到麻烦,可以找 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 的目录中。但是默认情况下,what's in the _layouts directory is packaged in a theme 所以看不到目录是正常的。所以我只是将_layoutsminimal-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 未能从例如 GitHub 存储库中读取必要的文件

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

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

我怀疑 jekyll-remote-theme 在本地环境中不起作用,所以我在 Google 上搜索了“jekyll 远程主题服务”,但没有帮助。

谷歌搜索关键字,如“远程主题构建警告:布局不存在”。没有太大帮助。

我该如何解决这个问题?

【问题讨论】:

    标签: ruby windows github jekyll github-pages


    【解决方案1】:

    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" 并修复了它——doh!

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

    希望有帮助!

    【讨论】:

    • 啊有这个comment on an issue 可以解释它
    • gem "jekyll-remote-theme"group do 的外部移动到Gemfile 的内部,在_config.yml 中添加了repository: Dixhom/dixhom.github.io,它解决了这个问题(dixhom.github.io)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-24
    • 2017-10-16
    • 1970-01-01
    • 1970-01-01
    • 2012-06-01
    • 1970-01-01
    相关资源
    最近更新 更多