Jekyll: 安装基于 gem 的主题

6
我已成功创建了我的第一个Jekyll v3.4.3静态网站。现在我想将默认的“minima”主题更改为另一个基于gem的主题,例如jekyll-theme-minimal
据我所了解,根据Jekyll文档,这只需要执行以下步骤:
1.- 将主题添加到您网站的Gemfile中:
gem "jekyll-theme-minimal", "~> 0.0.3"

2. 安装主题:

bundle install

3. 将以下内容添加到您网站的_config.yml中以激活该主题(注释掉“minima”并添加新主题):

theme: jekyll-theme-minimal

4.- 构建您的网站:


bundle exec jekyll serve

我按照这些步骤进行操作,但是构建网站(第四步)时出现以下错误:
$ bundle exec jekyll serve
Configuration file: /home/username/jekyll/myblog/_config.yml
Configuration file: /home/username/jekyll/myblog/_config.yml
            Source: /home/username/jekyll/myblog
       Destination: /home/username/jekyll/myblog/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
     Build Warning: Layout 'post' requested in _posts/2017-03-22-welcome-to-jekyll.markdown does not exist.
  Liquid Exception: Could not locate the included file 'icon-github.html' in any of ["/home/username/jekyll/myblog/_includes"]. Ensure it exists in one of those directories and, if it is a symlink, does not point outside your site source. in about.md

我看到新的基于gem的主题已经安装好了。

$ bundle show jekyll-theme-minimal
/home/username/.gem/ruby/2.4.0/gems/jekyll-theme-minimal-0.0.3

但我注意到新主题中没有 _includes 目录。另外,在我的 Jekyll 站点目录中,我看到 about.md 文件仍然引用默认的 "minima" 主题:

$ cat ~/jekyll/myblog/about.md 
---
layout: page
title: About
permalink: /about/
---

This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](https://jekyllrb.com/)

You can find the source code for the Jekyll new theme at:
{% include icon-github.html username="jekyll" %} /
[minima](https://github.com/jekyll/minima)

You can find the source code for Jekyll at
{% include icon-github.html username="jekyll" %} /
[jekyll](https://github.com/jekyll/jekyll)

我怎样在我的网站上将默认的“Minima”主题更改为基于Gem的其他主题?

1个回答

6
Jekyll主题文档说明了使用新主题的一般步骤,但是由于Jekyll非常灵活,它无法保证每个主题都能直接使用。 Jekyll默认安装包含示例数据、页面布局和包含内容。
"Minimal"主题具有默认布局和没有包含内容的特点。由于随Jekyll提供的示例文章使用包含内容并使用页面布局,因此不能直接使用“Minimal”主题。
安装完“Minimal”主题后,需要确保所有文章的布局为“default”(不要使用页面布局或其他任何布局),且文章内容中没有包含内容。
在这种情况下,调整“about.md”的方法如下所示:
---
layout: default
title: About
permalink: /about/
---

This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](https://jekyllrb.com/)

You can find the source code for the Jekyll new theme at:
[minima](https://github.com/jekyll/minima)

You can find the source code for Jekyll at
[jekyll](https://github.com/jekyll/jekyll)

或者,如果您不想更改帖子的内容,只需提供缺失的包含文件和/或布局文件,创建这些文件夹并创建所需的缺失文件,以便使用新主题,您不仅限于使用主题使用的内容 覆盖主题默认设置


1
好的解释,它帮助了我很多。看起来Jekyll并不像我想象中那么容易,我会继续阅读文档以获得更多知识。 - rodrunner

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接