Windows 10.0.19044.2364
ruby 3.1.3p185(2022-11-24 修订版 1a6b16756e)[x64-mingw-ucrt]
宝石 v3.3.26
杰基尔 4.3.1
使用 minima 主题将我的 Gemfile 和 _config.yml 设置为默认配置,一切都会按预期工作。当我尝试更改为另一个主题(任何主题)时,该网站无法正确加载。
我的默认 Gemfile:
source "https://rubygems.org"
# gem "jekyll", "~> 4.3.1"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima"
gem "github-pages", "~> 227", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.12"
gem "jekyll-remote-theme"
end
...
我的默认_config.yml:
title: default theme...
email: [email protected]
description: ...description...
domain: "chrisxfire.github.io"
url: "http://chrisxfire.github.io"
# Build settings
theme: minima
# remote-theme: pages-themes/[email protected]
plugins:
- jekyll-feed
- jekyll-remote-theme
GitHub Pages 正确生成站点,页面正常:
接下来,我尝试使用 GitHub Pages 支持的主题,例如午夜。我做了以下更改:
在 Gemfile 中,我将行
gem "minima"
更改为:
gem "jekyll-theme-midnight"
在 _config.yml 中,我将行
theme: minima
更改为:
theme: jekyll-theme-midnight
然后我就承诺了。 GitHub Actions 成功完成,但我现在网站上有一个空白页面。
接下来,按照午夜主题 GitHub 站点上的说明,我尝试对 _config.yml 进行以下更改:
# theme: jekyll-theme-midnight
remote-theme: pages-themes/[email protected]
然后我就承诺了。 GitHub Actions 成功完成。但是,页面仅呈现蓝色标题,没有其他内容:我做错了什么?
为了以午夜黑色显示页面,我已将您的 github-pages gem 移至 Gemfile 中的插件中:
source "https://rubygems.org"
group :jekyll_plugins do
gem "github-pages"
gem "jekyll-feed", "~> 0.12"
gem "jekyll-remote-theme"
end
此外,页面和帖子中当前的帖子和主页布局会在启动服务器时发出警告。您应该在构建日志中看到它们。您的 Gemfile 中不再需要该主题,因为您在 _config.yml 中使用远程主题选项。
layout: home
/
layout: page
/
layout: post
等(从
.markdown
/
.md
文件)或更改为
layout: default
,因为它是午夜主题中唯一可用的(请参阅:午夜/_布局)。 使用不存在的布局会导致页面显示出现问题。
执行后也可以看到这样的警告
bundle exec jekyll serve
:
Build Warning: Layout 'post' requested in _posts/2023-11-24-welcome-to-jekyll.markdown does not exist.
Build Warning: Layout 'page' requested in about.markdown does not exist.
Build Warning: Layout 'home' requested in index.markdown does not exist.
Build Warning: Layout 'page' requested in markdown.MD does not exist.
如果您想在主题中使用 home
、
page
、
post
等不支持开箱即用的布局,则需要将它们放入
_layouts
文件夹中(如果不存在,请创建这样的文件夹)。请注意,它可能需要更多的工作,而不仅仅是从另一个主题复制 html 文件。