今后将转到在github上写博客
Jekyll是一个ruby工具,可以根据静态文本搭建网站。
Github Pages功能的后端引擎就是jekyll,因此只要你的项目包含了jekyll配置,就可以在Github上免费建立博客。
jekyll 通过ruby安装工具gem安装
sudo apt-get install rubygems
可以添加源
gem sources -a http://ruby.taobao.org/
安装jekyll
sudo gem install Jekyll
安装过程中我遇到几处错误:
hailin@hailin-VirtualBox:~/win7/MyProjects $sudo gem install jekyll
extconf.rb:1:in `require': no such file toload -- mkmf (LoadError)
安装依赖
$ sudo apt-get install build-essential libopenssl-rubyruby1.8-dev
http://ruby.about.com/od/faqs/qt/Extconf-Rb-1-In-Require-No-Such-File-To-Load-Mkmf-Loaderror.htm
hailin@hailin-VirtualBox:~/win7/MyProjects $sudo gem install jekyll
Successfully installed jekyll-1.0.3
1 gem installed
Installing ri documentation forjekyll-1.0.3...
ERROR: While generating documentation for jekyll-1.0.3
... MESSAGE: Unhandled special: Special: type=17,text="<!-- more -->"
... RDOC args: --ri --op/var/lib/gems/1.8/doc/jekyll-1.0.3/ri --charset=UTF-8 --quiet libREADME.textile LICENSE --title jekyll-1.0.3 Documentation
(continuing with the rest of theinstallation)
Installing RDoc documentation forjekyll-1.0.3...
看来是安装成功了,但是ri documentation安装失败。找到一个办法创建~/.gemrc文件,内容为
gem: --no-ri --no-rdoc
http://stackoverflow.com/questions/1381725/how-to-make-no-ri-no-rdoc-the-default-for-gem-install
运行时又发现错误
hailin@hailin-VirtualBox:~/win7/MyProjects $sudo gem install jekyll
Successfully installed jekyll-1.0.3
1 gem installed
Installing ri documentation forjekyll-1.0.3...
ERROR: While executing gem ... (NoMethodError)
undefinedmethod `map' for Gem::Specification:Class
因为安装时是用sudo安装的,文件被安装到了/var/lib/gems/1.8目录下,但是该路径不在PATH环境变量中。
hailin@hailin-VirtualBox:~/win7/MyProjects$ls /var/lib/gems/1.8/gems/jekyll-1.0.3/
bin CONTRIBUTING.md cucumber.yml features Gemfile History.markdown jekyll.gemspec lib LICENSE Rakefile README.textile script site test
需要在/etc/profile中添加PATH
export PATH=$PATH:/var/lib/gems/1.8/bin #Add RVM to PATH for scripting
到此jekyll就安装成功了
hailin@hailin-VirtualBox:~/win7/MyProjects$jekyll new hailinzeng.github.com
New jekyll site installed in/home/hailin/win7/MyProjects/hailinzeng.github.com
Jekyll new myblog生成网站默认文件/文件夹,大致包括:
设置文件:_config.yml
模版文件:_layouts
文章目录:_post
Jekyll serve启动网站,在127.0.0.1:4000可查看页面。
添加文章只需要在_post目录下添加文件,文件名的格式为:年-月-日-文章标题.md,后缀MD是MarkDown文件,我使用的是MarkDownPad编辑。
每篇文章的头部,有一个yaml文件头,用来设置一些元数据。它用三根短划线"---",标记开始和结束,里面每一行设置一种元数据。
更多jekyll的配置可以参考:
http://jekyllrb.com/docs/structure/
http://www.ruanyifeng.com/blog/2012/08/blogging_with_jekyll.html
如果不想自己订制,也可以不安装jekyll,直接fork别人的项目修改,比如jekyllbootstrap,http://jekyllbootstrap.com/