在 GitHub 个页面上安装 Jekyll 3.8.5

Installing Jekyll 3.8.5 on GitHub Pages

描述

我正在尝试按照 https://help.github.com/en/github/working-with-github-pages/creating-a-github-pages-site-with-jekyll 中所述使用 GitHub 页面和 Jekyll 3.8.5 来设置我的个人网站,但捆绑程序出现问题。

详情

Bundle 找不到已安装的 Jekyll 3.8.5

$ bundle exec jekyll 3.8.5 new .
fatal: 'jekyll 3.8.5' could not be found. You may need to install the jekyll-3.8.5 gem or a related gem to be able to use this subcommand.`

验证我确实有 jekyll-3.8.5

$ bundle info jekyll                                                                                                                                                                                        
  * jekyll (3.8.5)
    Summary: A simple, blog aware, static site generator.
    Homepage: https://github.com/jekyll/jekyll
    Path: /Users/macikportali/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/jekyll-3.8.5

Gemfile(与 bundle install 一起安装)

source "https://rubygems.org"
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
#     bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
# gem "jekyll", "~> 4.0.0"
# gem "jekyll", "~> 3.8.5"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima", "~> 2.5"
gem "jekyll-athena"

# Seems this is needed to install a lot of subcommands, see: https://github.com/jekyll/jekyll-compose
gem 'jekyll-compose', group: [:jekyll_plugins]

# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
# gem "github-pages", group: :jekyll_plugins
# for jekyll 3.8.5
gem "github-pages", "204", group: :jekyll_plugins

# If you have any plugins, put them here!
group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.11"
end

# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
# and associated library.
install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do
  gem "tzinfo", "~> 1.2"
  gem "tzinfo-data"
end

# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.1", :install_if => Gem.win_platform?

Jekyll 与垫片一起使用

$ which jekyll
/Users/macikportali/.rbenv/shims/jekyll

我当前的 rbenv 版本

$ rbenv version
2.7.1 (set by /Users/macikportali/.rbenv/version)

问题

为什么 bundler 看不到安装的 jekyll-3.8.5 gem?

好的,我想我明白了。我有两个不同版本的 Jekyll。

$ gem list jekyll

*** LOCAL GEMS ***

jekyll (4.0.1, 3.8.5)

我所做的是在版本中添加下划线(_)作为前缀和后缀,从而执行

bundle exec jekyll _3.8.5_ new docs

这解决了问题,因为我相信这是 gem 在您有不同版本时遵循的惯例。

现在,我有一个不同的问题,即 404 页面,但这是另一个需要处理的问题。