1.安装Ruby
下载Ruby,安装到c:\ruby,Ruby版本请选择1.9.3。
2.安装Ruby DevKit
下载Ruby Development Kit,解压到c:\devkit,然后在c:\devkit下输入:
ruby dk.rb init
生成config.yml
查看config.yml文档,文档内容应该有下面类似的结构:
# 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:/Ruby193
3.安装jekyll
在c:\devkit\的命令行输入
ruby dk.rb install
gem sources --remove http://rubygems.org/
gem sources -a http://ruby.taobao.org/
gem sources -l
*** CURRENT SOURCES ***
http://ruby.taobao.org
gem install jekyll
4.安装python easy_install
python的版本的必须为2.7,不能为3.0。如果系统安装两个python版本,修改环境变量,使运行python版本为2.7。
下载安装easy_install
5.安装pygments
easy_install Pygments
6.运行jekyll
jekyll new blog
cd blog
jekyll serve
7.问题解决
7.1 ruby版本问题
jekyll serve
出现
Generating... Liquid Exception: cannot load such file -- yajl/2.0/yajl
请安装ruby版本1.9.3
7.2 jekyll源问题
gem install jekyll 出现:
ERROR: Could not find a valid gem 'jekyll' (>= 0) in any repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ECONNREFUSED: No connection could be made because the target machine
actively refused it. - connect(2) (https://rubygems.org/latest_specs.4.8.gz)
参考这个链接 得出解决方案:
$ gem sources --remove http://rubygems.org/
$ gem sources -a http://ruby.taobao.org/
$ gem sources -l
*** CURRENT SOURCES ***
http://ruby.taobao.org
%gem install rack
gem install jekyll
7.3 python问题
jekyll serve
出现如下错误:
Configuration file: c:/blog/_config.yml
Source: c:/blog
Destination: c:/blog/_site
Generating... C:/Ruby193/lib/ruby/gems/1.9.1/gems/posix-spawn-0.3.8/lib/po
six/spawn.rb:162: warning: cannot close fd before spawn
'which' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
[31m Liquid Exception: Failed to get header. in _posts/2014-04-29-welcome-to-j
ekyll.markdown [0m
error: Failed to get header.. Use --trace to view backtrace
请安装python版本2.7和pygments
7.4 中文编码问题
jekyll serve
出现
Generating... Error reading file c:/blog/_posts/2014-04-29-welcome-to-jeky
ll.markdown: invalid byte sequence in GBK
error: invalid byte sequence in GBK. Use --trace to view backtrace
在C:\Ruby193\lib\ruby\gems\1.9.1\gems\jekyll-1.5.1\lib\jekyll\convertible.rb的38行
self.content = File.read_with_options(File.join(base, name)
改为
opts = {:encoding=>"utf-8"}`
self.content = File.read_with_options(File.join(base, name)
或者
在_config.yml中加入
encoding:utf-8
8. 参考
http://www.madhur.co.in/blog/2011/09/01/runningjekyllwindows.html
http://www.cnblogs.com/yevon/p/3310857.html
http://liouys.github.io/jekyll/2013/06/10/jekyll-usage-faq.html