Jekyll is a simple, blog-aware, static site generator. It takes a template directory containing raw text files in various formats, runs it through a converter (like Markdown) and our Liquid renderer, and spits out a complete, ready-to-publish static website suitable for serving with your favorite web server. Jekyll also happens to be the engine behind GitHub Pages, which means you can use Jekyll to host your project’s page, blog, or website from GitHub’s servers for free.
上面这段话是jekyll官网关于jekyll的介绍,简单来说,jekyll是一个可以将markdown文档转化为静态html站点的工具。接下来介绍一下如何在Ubuntu 16.04 LTS上安装这个工具。
lwk@qwfys ~$ sudo gem install jekyll
[sudo] password for lwk:
Fetching: public_suffix-3.0.0.gem (100%)
Successfully installed public_suffix-3.0.0
Fetching: addressable-2.5.2.gem (100%)
Successfully installed addressable-2.5.2
Fetching: colorator-1.1.0.gem (100%)
Successfully installed colorator-1.1.0
Fetching: rb-fsevent-0.10.2.gem (100%)
Successfully installed rb-fsevent-0.10.2
Fetching: ffi-1.9.18.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/ffi-1.9.18/ext/ffi_c
/usr/bin/ruby2.3 -r ./siteconf20170907-2115-63wl75.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/ffi-1.9.18 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.18/gem_make.out
用谷歌搜索:can't find header files for ruby at /usr/lib/ruby/include/ruby.h
选择最后一项,即
根据askubuntu.com网站的介绍,我们知道缺失了ruby-dev zlib1g-dev liblzma-dev。于是先安装这几个组件。
lwk@qwfys ~ $ sudo apt-get install ruby-dev zlib1g-dev liblzma-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libc-dev-bin libc6-dev libgmp-dev libgmpxx4ldbl ruby2.3-dev
Suggested packages:
glibc-doc gmp-doc libgmp10-doc libmpfr-dev liblzma-doc
The following NEW packages will be installed:
libc-dev-bin libc6-dev libgmp-dev libgmpxx4ldbl liblzma-dev ruby-dev ruby2.3-dev zlib1g-dev
0 upgraded, 8 newly installed, 0 to remove and 1 not upgraded.
Need to get 3,814 kB of archives.
After this operation, 21.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.ustc.edu.cn/ubuntu xenial-updates/main amd64 libc-dev-bin amd64 2.23-0ubuntu9 [68.6 kB]
Get:2 http://mirrors.ustc.edu.cn/ubuntu xenial-updates/main amd64 libc6-dev amd64 2.23-0ubuntu9 [2,082 kB]
Get:3 http://mirrors.ustc.edu.cn/ubuntu xenial/main amd64 libgmpxx4ldbl amd64 2:6.1.0+dfsg-2 [8,948 B]
Get:4 http://mirrors.ustc.edu.cn/ubuntu xenial/main amd64 libgmp-dev amd64 2:6.1.0+dfsg-2 [314 kB]
Get:5 http://mirrors.ustc.edu.cn/ubuntu xenial-updates/main amd64 ruby2.3-dev amd64 2.3.1-2~16.04.2 [1,032 kB]
Get:6 http://mirrors.ustc.edu.cn/ubuntu xenial/main amd64 ruby-dev amd64 1:2.3.0+1 [4,408 B]
Get:7 http://mirrors.ustc.edu.cn/ubuntu xenial-updates/main amd64 zlib1g-dev amd64 1:1.2.8.dfsg-2ubuntu4.1 [168 kB]
Get:8 http://mirrors.ustc.edu.cn/ubuntu xenial/main amd64 liblzma-dev amd64 5.1.1alpha+20120614-2ubuntu2 [137 kB]
Fetched 3,814 kB in 2s (1,347 kB/s)
Selecting previously unselected package libc-dev-bin.
(Reading database ... 218877 files and directories currently installed.)
Preparing to unpack .../libc-dev-bin_2.23-0ubuntu9_amd64.deb ...
Unpacking libc-dev-bin (2.23-0ubuntu9) ...
Selecting previously unselected package libc6-dev:amd64.
Preparing to unpack .../libc6-dev_2.23-0ubuntu9_amd64.deb ...
Unpacking libc6-dev:amd64 (2.23-0ubuntu9) ...
Selecting previously unselected package libgmpxx4ldbl:amd64.
Preparing to unpack .../libgmpxx4ldbl_2%3a6.1.0+dfsg-2_amd64.deb ...
Unpacking libgmpxx4ldbl:amd64 (2:6.1.0+dfsg-2) ...
Selecting previously unselected package libgmp-dev:amd64.
Preparing to unpack .../libgmp-dev_2%3a6.1.0+dfsg-2_amd64.deb ...
Unpacking libgmp-dev:amd64 (2:6.1.0+dfsg-2) ...
Selecting previously unselected package ruby2.3-dev:amd64.
Preparing to unpack .../ruby2.3-dev_2.3.1-2~16.04.2_amd64.deb ...
Unpacking ruby2.3-dev:amd64 (2.3.1-2~16.04.2) ...
Selecting previously unselected package ruby-dev:amd64.
Preparing to unpack .../ruby-dev_1%3a2.3.0+1_amd64.deb ...
Unpacking ruby-dev:amd64 (1:2.3.0+1) ...
Selecting previously unselected package zlib1g-dev:amd64.
Preparing to unpack .../zlib1g-dev_1%3a1.2.8.dfsg-2ubuntu4.1_amd64.deb ...
Unpacking zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ...
Selecting previously unselected package liblzma-dev:amd64.
Preparing to unpack .../liblzma-dev_5.1.1alpha+20120614-2ubuntu2_amd64.deb ...
Unpacking liblzma-dev:amd64 (5.1.1alpha+20120614-2ubuntu2) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Setting up libc-dev-bin (2.23-0ubuntu9) ...
Setting up libc6-dev:amd64 (2.23-0ubuntu9) ...
Setting up libgmpxx4ldbl:amd64 (2:6.1.0+dfsg-2) ...
Setting up libgmp-dev:amd64 (2:6.1.0+dfsg-2) ...
Setting up ruby2.3-dev:amd64 (2.3.1-2~16.04.2) ...
Setting up ruby-dev:amd64 (1:2.3.0+1) ...
Setting up zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ...
Setting up liblzma-dev:amd64 (5.1.1alpha+20120614-2ubuntu2) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
至此,ruby-dev zlib1g-dev liblzma-dev安装成功。于是继续安装jekyll。
lwk@qwfys ~ $ sudo gem install jekyll
Building native extensions. This could take a while...
Successfully installed ffi-1.9.18
Fetching: rb-inotify-0.9.10.gem (100%)
Successfully installed rb-inotify-0.9.10
Fetching: sass-listen-4.0.0.gem (100%)
Successfully installed sass-listen-4.0.0
Fetching: sass-3.5.1.gem (100%)
Successfully installed sass-3.5.1
Fetching: jekyll-sass-converter-1.5.0.gem (100%)
Successfully installed jekyll-sass-converter-1.5.0
Fetching: listen-3.0.8.gem (100%)
Successfully installed listen-3.0.8
Fetching: jekyll-watch-1.5.0.gem (100%)
Successfully installed jekyll-watch-1.5.0
Fetching: kramdown-1.14.0.gem (100%)
Successfully installed kramdown-1.14.0
Fetching: liquid-4.0.0.gem (100%)
Successfully installed liquid-4.0.0
Fetching: mercenary-0.3.6.gem (100%)
Successfully installed mercenary-0.3.6
Fetching: forwardable-extended-2.6.0.gem (100%)
Successfully installed forwardable-extended-2.6.0
Fetching: pathutil-0.14.0.gem (100%)
Successfully installed pathutil-0.14.0
Fetching: rouge-1.11.1.gem (100%)
Successfully installed rouge-1.11.1
Fetching: safe_yaml-1.0.4.gem (100%)
Successfully installed safe_yaml-1.0.4
Fetching: jekyll-3.5.2.gem (100%)
Successfully installed jekyll-3.5.2
Parsing documentation for ffi-1.9.18
Installing ri documentation for ffi-1.9.18
Parsing documentation for rb-inotify-0.9.10
Installing ri documentation for rb-inotify-0.9.10
Parsing documentation for sass-listen-4.0.0
Installing ri documentation for sass-listen-4.0.0
Parsing documentation for sass-3.5.1
Installing ri documentation for sass-3.5.1
Parsing documentation for jekyll-sass-converter-1.5.0
Installing ri documentation for jekyll-sass-converter-1.5.0
Parsing documentation for listen-3.0.8
Installing ri documentation for listen-3.0.8
Parsing documentation for jekyll-watch-1.5.0
Installing ri documentation for jekyll-watch-1.5.0
Parsing documentation for kramdown-1.14.0
Installing ri documentation for kramdown-1.14.0
Parsing documentation for liquid-4.0.0
Installing ri documentation for liquid-4.0.0
Parsing documentation for mercenary-0.3.6
Installing ri documentation for mercenary-0.3.6
Parsing documentation for forwardable-extended-2.6.0
Installing ri documentation for forwardable-extended-2.6.0
Parsing documentation for pathutil-0.14.0
Installing ri documentation for pathutil-0.14.0
Parsing documentation for rouge-1.11.1
Installing ri documentation for rouge-1.11.1
Parsing documentation for safe_yaml-1.0.4
Installing ri documentation for safe_yaml-1.0.4
Parsing documentation for jekyll-3.5.2
Installing ri documentation for jekyll-3.5.2
Done installing documentation for ffi, rb-inotify, sass-listen, sass, jekyll-sass-converter, listen, jekyll-watch, kramdown, liquid, mercenary, forwardable-extended, pathutil, rouge, safe_yaml, jekyll after 21 seconds
15 gems installed
安装成功,这时检测一下是否安装成功。
15 gems installed
lwk@qwfys ~$ jekyll
A subcommand is required.
jekyll 3.5.2 -- Jekyll is a blog-aware, static site generator in Ruby
Usage:
jekyll <subcommand> [options]
Options:
-s, --source [DIR] Source directory (defaults to ./)
-d, --destination [DIR] Destination directory (defaults to ./_site)
--safe Safe mode (defaults to false)
-p, --plugins PLUGINS_DIR1[,PLUGINS_DIR2[,...]] Plugins directory (defaults to ./_plugins)
--layouts DIR Layouts directory (defaults to ./_layouts)
--profile Generate a Liquid rendering profile
-h, --help Show this message
-v, --version Print the name and version
-t, --trace Show the full backtrace when an error occurs
Subcommands:
docs
import
build, b Build your site
clean Clean the site (removes site output and metadata file) without building.
doctor, hyde Search site and print specific deprecation warnings
help Show the help message, optionally for a given subcommand.
new Creates a new Jekyll site scaffold in PATH
new-theme Creates a new Jekyll theme scaffold
serve, server, s Serve your site locally
确实安装成功。