jekyll环境配置及问题解决方法

(1)-在本地配置好 github客户端
打开 http://jekyllbootstrap.com/index.html 依次配置

搭建ruby+devkit:
(2)-rubyinstaller-1.9.3-p392.exe
(3)-DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe

安装jekyll:

gem install jekyll
cd USERNAME.github.com 
jekyll --server

参考:
http://rubygems.org/gems/jekyll
http://jekyllbootstrap.com/usage/jekyll-quick-start.html

配置

安装代码高亮:

cd c:Ruby193librubygems1.9.1gemspygments.rb-0.3.7vendorpygments-main
python setup.py install

生成样式:

pygmentize -S default -f html > pygments.css

拷贝:
pygments.css 至 assets/themes/twitter/css

修改:
_includes/themes/twitter/default.html
添加:

<link href="/assets/themes/css/pygments.css" rel="stylesheet" type="text/css" media="all">
ruby
{% highlight ruby%}
def hello
	puts "hello"
end
{% endhighlight %}

python
{% highlight python%}
def hello
	print "hello"
{% endhighlight %}

java
{% highlight java%}
public static void main(String[] args) {
	System.out.println("Hello World");
}
{% endhighlight %}

遇到问题:
执行:

gem install jekyll

报错:

ERROR:  Error installing jekyll:
        The 'fast-stemmer' native gem requires installed build tools.

解决方法:

e:Program_Filesdevkit-tdm-32-4.5.2-20111229-1559-sfx>ruby dk.rb init

输出信息:
[INFO] found RubyInstaller v1.9.3 at E:/Program_Files/Ruby193

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.

e:Program_Filesdevkit-tdm-32-4.5.2-20111229-1559-sfx>ruby dk.rb install

输出信息:
[INFO] Updating convenience notice gem override for ‘E:/Program_Files/Ruby193’
[INFO] Installing ‘E:/Program_Files/Ruby193/lib/ruby/site_ruby/devkit.rb’

再执行:

gem install jekyll

输出如下信息:
Temporarily enhancing PATH to include DevKit…
Building native extensions. This could take a while…
Fetching: classifier-1.3.3.gem (100%)
Fetching: directory_watcher-1.5.1.gem (100%)
Fetching: syntax-1.0.0.gem (100%)
Fetching: maruku-0.6.1.gem (100%)
Fetching: kramdown-0.14.2.gem (100%)
Fetching: yajl-ruby-1.1.0-x86-mingw32.gem (100%)
Fetching: posix-spawn-0.3.6.gem (100%)
Building native extensions. This could take a while…
Fetching: pygments.rb-0.3.7.gem (100%)
Fetching: jekyll-0.12.1.gem (100%)
Successfully installed fast-stemmer-1.0.2
Successfully installed classifier-1.3.3
Successfully installed directory_watcher-1.5.1
Successfully installed syntax-1.0.0
Successfully installed maruku-0.6.1
Successfully installed kramdown-0.14.2
Successfully installed yajl-ruby-1.1.0-x86-mingw32
Successfully installed posix-spawn-0.3.6
Successfully installed pygments.rb-0.3.7
Successfully installed jekyll-0.12.1
10 gems installed
Installing ri documentation for fast-stemmer-1.0.2…
Installing ri documentation for classifier-1.3.3…
Installing ri documentation for directory_watcher-1.5.1…
Installing ri documentation for syntax-1.0.0…
Installing ri documentation for maruku-0.6.1…
Couldn’t find file to include ‘MaRuKu.txt’ from lib/maruku.rb
Installing ri documentation for kramdown-0.14.2…
Installing ri documentation for yajl-ruby-1.1.0-x86-mingw32…
Installing ri documentation for posix-spawn-0.3.6…
Installing ri documentation for pygments.rb-0.3.7…
Installing ri documentation for jekyll-0.12.1…
Installing RDoc documentation for fast-stemmer-1.0.2…
Installing RDoc documentation for classifier-1.3.3…
Installing RDoc documentation for directory_watcher-1.5.1…
Installing RDoc documentation for syntax-1.0.0…
Installing RDoc documentation for maruku-0.6.1…
Couldn’t find file to include ‘MaRuKu.txt’ from lib/maruku.rb
Installing RDoc documentation for kramdown-0.14.2…
Installing RDoc documentation for yajl-ruby-1.1.0-x86-mingw32…
Installing RDoc documentation for posix-spawn-0.3.6…
Installing RDoc documentation for pygments.rb-0.3.7…
Installing RDoc documentation for jekyll-0.12.1…

问题二:
YAML Exception reading index.md: invalid byte sequence in GB2312
Liquid Exception: invalid byte sequence in GB2312 in index.md
首先使用:

jekyll --server --no-auto

命令查看 Ruby 报错(也可以将 _config.yml 中的 auto: true 改为 auto: false),可能会出现一坨错误,其中可能包含invalid byte sequence in GBK字样。

读取的文件编码不对:
找到 C:Ruby193librubygems1.9.1gemsjekyll-0.11.2libjekyllconvertible.rb 28行

self.content = File.read(File.join(base, name))

将其修改为:

self.content = File.read(File.join(base, name), :encoding => "utf-8")

参考地址:http://higrid.net/c-art-jekyll_post_draft.htm

最后跑一下执行:
打开Git Shell

cd USERNAME.github.com 
jekyll --server --no-auto

打开:http://localhost:4000/ 成功啦。

评论已关闭。