使用 Jekyll



各类命令:

要启动 Jekyll 服务器、清理、更新、安装依赖包,请运行:

bundle exec jekyll serve
bundle exec jekyll clean 
bundle update jekyll
bundle install


Caution

有时 Gemfile.lock 会锁定一个不同版本的 Bundler。请核实:

gem list bundler
tail -n +1 Gemfile.lock | sed -n '/BUNDLED WITH/,$p'

删除该文件即可解决问题。

Important

千万不要用 sudo 运行 bundle


要将 Bundler 更新到与你的 Ruby 版本兼容的版本,并检查 / 卸载旧版本:

sudo gem update --system
sudo gem update bundler
sudo gem install bundler 
gem list bundler    
sudo gem uninstall bundler -v 2.6.5

有时需要彻底清除 Bundler 并重新安装:

sudo rm -f /opt/homebrew/bin/bundle /opt/homebrew/bin/bundler
sudo gem uninstall bundler -aIx


缺失的扩展

以下这类消息:

Source locally installed gems is ignoring #<Bundler::StubSpecification name=nokogiri version=1.18.3 platform=ruby> because it is missing extensions

可以通过执行以下命令来解决:

gem pristine <module>
bundle install


样式


提示框(Admonitions):

将以下内容添加到 gemfile 中的 jekyll_plugins 分组,即可在 Markdown 文件中启用提示框:

  gem "jekyll-gfm-admonitions"

提示框可以这样实现:

> [!NOTE] 
> Note text line1
> Note text line2

可用的提示框类型有:

[!NOTE], [!TIP], [!WARNING], [!CAUTION], [!IMPORTANT]


添加内容

对于以下划线开头的目录中的文件, 如果在 _config.yml 文件中按如下方式指定,Jekyll 将不会处理它们:

# this add content to the website from the local dirs starting with _
collections:
  pi0:
    output: true


可以选择性地添加固定链接(permalinks)以便于导航。


其他 Markdown 功能



实用链接: