[英]Jekyll: installing a gem-based theme
我已經成功地使用 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
我遵循了這些步驟,但是構建站點(第 4 步)會出現以下錯誤:
$ 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)
如何在我的站點中將默認的“最小”主題更改為另一個基於 gem 的主題?
Jekyll 主題文檔指定了使用新主題的一般過程,但由於 Jekyll非常靈活,它不能保證每個主題都能開箱即用。
Jekyll 默認安裝,帶有示例數據、頁面布局和包含.
Minimal主題有一個默認布局並且沒有包含,因為 Jekyll 附帶的示例帖子使用包含並使用頁面布局,它不會工作。
安裝最小主題后,您需要確保所有帖子都具有layout: default作為其布局(無布局:頁面或任何其他布局),並且帖子內容沒有includes 。
在這種情況下,像這樣調整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)
或者,如果您不想更改帖子的內容,只需提供丟失的包含和/或布局,以創建這些文件夾並創建您希望使用新主題的正確丟失文件,您不僅限於使用主題使用什么覆蓋主題默認
我的感覺與您的感覺完全一樣-Jekyll易於設置,但是要花很多精力才能了解其中的內容。 我嘗試采用默認最小主題下的投資組合主題,並遇到許多問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.