01 November 2013

Jekyll(发音/’dʒiːk əl/,”杰克尔”)是一个静态站点生成器,它会根据网页源码生成静态文件。它提供了模板、变量、插件等功能,所以实际上可以用来编写整个网站。

下载rubyinstaller、rubydevkit

http://rubyinstaller.org/downloads/

rubyinstaller安装结束后,运行ruby -v显示版本号。如果正常显示Ruby版本号,表示安装成功。

打开CMD进入DevKit解压后的目录,开始初始化安装

ruby dk.rb init
ruby dk.rb install

rubyinstaller、rubydevkit版本号要对应起来,否则会出现“Invalid configuration. Please fix 'config.yml.'”

安装jkeyll

gem install jekyll

安装完成后,可以使用jekyll -v来检查是否安装成功

由于国内网络原因,导致 rubygems.org 存放在 Amazon S3 上面的资源文件间歇性连接失败(http://ruby.taobao.org/)。

gem sources --remove https://rubygems.org/
gem sources -a http://ruby.taobao.org/

Running Jekyll on Windows

http://www.madhur.co.in/blog/2011/09/01/runningjekyllwindows.html

jekyll build
jekyll build --watch
jekyll serve
jekyll serve --detach
jekyll serve --watch

jekyll 中文编码问题

今天在本地预览jekyll搭建的小博客出现如下错误:

Conversion error: There was an error converthing 'index.md'.

找到C:\Ruby200-x64\lib\ruby\gems\2.0.0\gems\jekyll-1.2.1\lib\jekyll\convertible.rb

修改:

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

为:

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

mac

Install with RubyGems

gem install jekyll

jekyll build
# => The current folder will be generated into ./_site

jekyll build --watch
# => The current folder will be generated into ./_site,
#    watched for changes, and regenerated automatically.

jekyll serve
# => A development server will run at http://localhost:4000/

jekyll serve --detach
# => Same as `jekyll serve` but will detach from the current terminal.
#    If you need to kill the server, you can `kill -9 1234` where "1234" is the PID.
#    If you cannot find the PID, then do, `ps aux | grep jekyll` and kill the instance. [Read more](http://unixhelp.ed.ac.uk/shell/jobz5.html).

jekyll serve --watch
# => Same as `jekyll serve`, but watch for changes and regenerate automatically.