捣鼓了几天终于把博客搭出来了,之前不认识Jekyll,费劲查了很多资料,在此把我安装的过程和遇到的问题整理一下,做一个详细的教程,希望刚接触Jekyll且没头绪的同学们能省点事。

说明:主要参考官方文档和叶的一篇文章http://www.cnblogs.com/yevon/archive/2013/09/19/3310857.html

  • 这里下载Ruby和Ruby Development Kit,注意32位和64位,两个要保持一致。
  • 安装Ruby并添加环境变量,例:C:\Ruby200-x64(安装过程中有自动添加环境变量的选项)
  • 解压DevKit到任意目录,例:C:\RubyDevKit
  • 打开CMD切换到DevKit目录下,运行命令ruby dk.rb init
C:\RubyDevKit>ruby dk.rb init
Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.

  此时会生成一个配置文件config.yml.用记事本打开,将你安装Ruby的目录填进去,如下:

# This configuration file contains the absolute path locations of all
# installed Rubies to be enhanced to work with the DevKit. This config
# file is generated by the 'ruby dk.rb init' step and may be modified
# before running the 'ruby dk.rb install' step. To include any installed
# Rubies that were not automagically discovered, simply add a line below
# the triple hyphens with the absolute path to the Ruby root directory.
#
# Example:
#
# ---
# - C:/ruby19trunk
# - C:/ruby192dev
#
---
- C:/Ruby200-x64
  • 接着运行命令ruby dk.rb install
C:\RubyDevKit>ruby dk.rb install
[INFO] Updating convenience notice gem override for 'C:/Ruby200-x64'
[INFO] Installing 'C:/Ruby200-x64/lib/ruby/site_ruby/devkit.rb'
  • 安装Jekyll,运行命令gem install jekyll
C:\RubyDevKit>gem install jekyll
Fetching: liquid-2.5.5.gem (100%)
Successfully installed liquid-2.5.5
Fetching: fast-stemmer-1.0.2.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed fast-stemmer-1.0.2
..............省略..............
Parsing documentation for jekyll-2.0.3
Installing ri documentation for jekyll-2.0.3
27 gems installed

至此,Jekyll已经可以使用了,可通过以下命令建立博客

jekyll new myblog  在当前目录下新建名为myblog的目录
cd myblog
jekyll serve       编译并开启本地服务

完成后可通过http://localhost:4000预览。将myblog目录下所有文件拷贝至Git库并提交到GitHub即可。


若需要代码高亮支持,请继续以下步骤。

  • 安装Portable Python(官方放推荐2.x版本,2.7.5以上,可从这里下载)
  • 添加环境变量,例:C:\Portable Python 2.7.5.1\App
  • 安装Pygments,运行命令easy_install Pygments
C:\Portable Python 2.7.5.1\App\Scripts>easy_install Pygments
Searching for Pygments
Reading http://pypi.python.org/simple/Pygments/
Best match: Pygments 1.6
Downloading https://pypi.python.org/packages/2.7/P/Pygments/Pygments-1.6-py2.7.e
gg#md5=1e1e52b1e434502682aab08938163034
Processing Pygments-1.6-py2.7.egg
creating c:\portable python 2.7.5.1\app\lib\site-packages\Pygments-1.6-py2.7.egg

Extracting Pygments-1.6-py2.7.egg to c:\portable python 2.7.5.1\app\lib\site-pac
kages
Adding Pygments 1.6 to easy-install.pth file
Installing pygmentize-script.py script to C:\Portable Python 2.7.5.1\App\Scripts

Installing pygmentize.exe script to C:\Portable Python 2.7.5.1\App\Scripts
Installing pygmentize.exe.manifest script to C:\Portable Python 2.7.5.1\App\Scri
pts

Installed c:\portable python 2.7.5.1\app\lib\site-packages\pygments-1.6-py2.7.eg
g
Processing dependencies for Pygments
Finished processing dependencies for Pygments

若想成功编译需要Pygments版本0.5.0,高版本会报错,可通过gem list命令查看当前版本。

C:\>gem list

*** LOCAL GEMS ***

bigdecimal (1.2.0)
blankslate (2.1.2.4)
celluloid (0.15.2)
classifier (1.3.4)
coffee-script (2.2.0)
coffee-script-source (1.7.0)
colorator (0.1)
execjs (2.0.2)
fast-stemmer (1.0.2)
ffi (1.9.3 x64-mingw32)
io-console (0.4.2)
jekyll (2.0.3)
jekyll-coffeescript (1.0.0)
jekyll-sass-converter (1.0.0)
json (1.7.7)
kramdown (1.3.3)
liquid (2.5.5)
listen (2.7.5)
mercenary (0.3.3)
minitest (4.3.2)
parslet (1.5.0)
posix-spawn (0.3.8)
psych (2.0.0)
pygments.rb (0.5.4)    --当前版本
rake (0.9.6)
rb-fsevent (0.9.4)
rb-inotify (0.9.4)
rdoc (4.0.0)
redcarpet (3.1.2)
safe_yaml (1.0.3)
sass (3.3.7)
test-unit (2.0.0.0)
timers (1.1.0)
toml (0.1.1)
yajl-ruby (1.1.0)

若版本高于0.5.0需要手动安装低版本,输入gem install pygments.rb --version "=0.5.0"命令安装。

C:\>gem install pygments.rb --version "=0.5.0"
Fetching: pygments.rb-0.5.0.gem (100%)
Successfully installed pygments.rb-0.5.0
Parsing documentation for pygments.rb-0.5.0
Installing ri documentation for pygments.rb-0.5.0
1 gem installed

再卸载高版本gem uninstall pygments.rb --version "=0.5.4"(替换你对应的版本号)。

C:\>gem uninstall pygments.rb --version "=0.5.4"
Successfully uninstalled pygments.rb-0.5.4

大功告成。