首页 文章

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

提问于
浏览
6

摘要

  • 我想在Jekyll使用 gem "jekyll-remote-theme" 看到本地机器中的页面

  • 所以我跑了 bundle exec jekyll serve

  • 但是出现了一个空白页面

我想要实现的目标

  • 使用 gem "jekyll-remote-theme" 查看Jekyll制作的本地计算机中的页面 .

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

环境

  • Windows 8.1 64位

  • ruby 2.4.3p205(2017-12-14修订版61247)[x64-mingw32]

  • Jekyll 3.6.2

我做了什么

究竟发生了什么

我有一个与 libcurl.dll 相关的错误 . 以下是Powershell上的消息 .

依赖性错误:哎呀!看起来您没有安装jekyll-remote-theme或其依赖项 . 为了使用当前配置的Jekyll,您需要安装此gem . 来自Ruby的完整错误消息是:'无法打开库'libcurl':(非法字符) . 无法打开libr 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 failing to read necessary files from, for example, a GitHub repo .

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

enter image description here

顺便说一句,回购是https://github.com/Dixhom/dixhom.github.io/tree/7132905f5515345eb78cd71bdad168a15f906a1c

我怀疑 jekyll-remote-theme 并没有帮助 .

谷歌搜索关键字,如“远程主题生成警告:布局不存在” . 没多大帮助 .

我怎么解决这个问题?

1 回答

  • 2

    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!

    关于这个Gemfile组的jekyll changelogs中有一些注释,但我没有发现任何一个超级有助于解释这里发生了什么 .

    希望有所帮助!

相关问题