Jekyll
Jekyll¶
Jekyll is a Ruby Gem that can be installed on most systems.
- Ruby: 一种开源的面向对象程序设计的服务器端脚本语言,在 20 世纪 90 年代中期由日本的松本行弘(まつもとゆきひろ/Yukihiro Matsumoto)设计并开发。Ruby 教程
- Jekyll is written in Ruby.
- Gem: Gems are code you can include in Ruby projects. Jekyll is a gem. Many Jekyll plugins are also gems.
- Gemfile: a list of gems.
- Bundler: a gem that installs all gems in
Gemfile
. - RubyGems: Ruby 的一个包管理器,它提供一个分发 Ruby 程序和库的标准格式,还提供一个管理程序包安装的工具,类似于 Ubuntu 下的 apt-get, Centos 的 yum,Python 的 pip。https://rubygems.org/
run locally¶
# 0. install prerequisites: https://jekyllrb.com/docs/installation/ubuntu/
# 1. install the jekyll and bundler gems
gem install jekyll bundler
# 2. build the site locally
bundle exec jekyll serve
if it broken down, such as
/home/weiya/gems/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:14:in `<module:Middleware>': uninitialized constant Faraday::Error::ClientError (NameError)
try to update the local gem via
bundle update github-pages
unsupported plugins by Github pages¶
Github Pages sites are generated using the
--safe
option to disable plugins (with the exception of some whitelisted plugins) for security reasons. source: Plugins on GitHub Pages
If use third-party plugins, such as gjtorikian/jekyll-last-modified-at, there are two possible ways
- build locally
- use travis or github actions.
refer to How do I configure GitHub to use non-supported Jekyll site plugins?
Jekyll Part 13: Creating an Article Series¶
Jekyll Part 13: Creating an Article Series
Add an “Updated” field to Jekyll posts¶
Add an “Updated” field to Jekyll posts
博客中插入网易云音乐¶
这个很容易实现,只需要在网易云中搜索要插入的音乐,然后点击“生成外链播放器”,将iframe代码插入博客的相应位置。
比如,我想在不愿沉默如谜插入容祖儿的重生。点击页面中的“生成外链播放器”,将iframe代码放进原md文件中。但一开始有问题,iframe被当成普通的md文本。在Jekyll raw HTML in post中找到了答案。
网易云给的iframe代码为
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=522631413&auto=1&height=66"></iframe>
要将width=330 height=86
改成width="330" height="86"
,果然成功了。效果页面如下:
Jekyll add RSS feed¶
jekyll tags 逗号分隔¶
采用
{% for tag in page.tags %}
<a href="/tag/{{tag}}">{{tag}}</a>
{% unless forloop.last %},{% endunless %}
{% endfor %}
但 List of Dynamic Links in Jekyll 提到了更完整的方案,
{% capture tagscommas %}
{% for tag in page.tags %}
<a href="/tag/{{tag}}">{{tag}}</a>
{% unless forloop.last %},{% endunless %}
{% endfor %}
{% endcapture %}
{{tagscommas}}
Correct Jekyll¶
refer to Configuring Jekyll for User and Project GitHub Pages