[2]. jekyll安装与应用

一、ruby安装

这里在win下安装ruby,对应自己电脑的操作系统位数,如我的是64位,对应下载Ruby 2.0.0-p353 (x64)这个版本的ruby。然后安装过程就很简单了:

命令行下输入ruby -v 检测是否安装成功:

C:\Users\Administrator>ruby -v
ruby 2.0.0p353 (2013-11-22) [x64-mingw32]

出现版本号就说明安装成功了,接下来就要安装jekyll.

二、安装jekykll

最好在你的git bash下安装,据说在DOS命令下错误百出。安装过程如下:

$ gem install jekyll
Fetching: liquid-2.5.5.gem (100%)
Successfully installed liquid-2.5.5
Fetching: fast-stemmer-1.0.2.gem (100%)
ERROR:  Error installing jekyll:
The 'fast-stemmer' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

还是报错了,提示我们下载安装"DevKit",这里下载安装即可,然后又提示我们在http://github.com/oneclick/rubyinstaller/wiki/Development-Kit找答案。

上面提示说:

安装了DevKit后切换到DevKit的安装目录:cd

执行 ruby dk.rb init 生成config.yml配置文件

最后 ruby dk.rb install 安装 DevKit 到你ruby中。对于64位操作系统来说,可能会报错:‘Invalid configuration. Please fix ‘config.yml’ and rerun ‘ruby dk.rb install’`. 解决方案是将ruby目录的绝对路径写在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:\Ruby200-x64

注意规则:在---下,以 - 开头,然后空一格,然后是写ruby的绝对路径。

然后再试 ruby dk.rb install.如下提示:

$ 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
Temporarily enhancing PATH to include DevKit..
Building native extensions.  This could take a
Successfully installed fast-stemmer-1.0.2
Fetching: classifier-1.3.4.gem (100%)
Successfully installed classifier-1.3.4
Fetching: rb-fsevent-0.9.4.gem (100%)
......

检测是否安装成功:

$ jekyll -v
jekyll 1.4.3

提示ok了!

上面的最好参考文档

三、jekyll应用

下面举一个”用Jekyll构建基于bootstrap模板“ 的例子:
首先从github下载模板

$ git clone https://github.com/plusjade/jekyll-bootstrap.git jekyll 

然后进入项目目录,启动jekyll服务:

$ cd jekyll-bootstrap
$ jekyll serve

如果不出意外就会出现以下界面:

[2]. jekyll安装与应用

当然那些花花绿绿的线条和文字是我闲着无聊添加上去的。

如果像我一样运气不好,在启动时出现:以下错误:

$ jekyll serve
Configuration file: e:/jek_demo/jekyll-bootstrap/_config.yml
Source: e:/jek_demo/jekyll-bootstrap
   Destination: e:/jek_demo/jekyll-bootstrap/_site
  Generating... error: Invalid argument - e:/jek_demo/jekyll-bootstrap/_site
/e:. Use --trace to view backtrace

就说明你下载的jekyll是最新版,与你的ruby版本的问题,这里卸载最新版,安装1.4.2的版本的就行了:

# 卸载原先安装的最新版1.4.3的jekyll
$ gem uninstall jekyll
Remove executables:
jekyll

in addition to the gem? [Yn]  y
Removing jekyll
Successfully uninstalled jekyll-1.4.3

Administrator@FANGPENG /e/jek_demo/jekyll-bootstrap (master)
#安装1.4.2版本的
$ gem install jekyll --version "=1.4.2"
Fetching: jekyll-1.4.2.gem (100%)
Successfully installed jekyll-1.4.2
Parsing documentation for jekyll-1.4.2
Installing ri documentation for jekyll-1.4.2
1 gem installed

Administrator@FANGPENG /e/jek_demo/jekyll-bootstrap (master)
$ jekyll -v
jekyll 1.4.2

Administrator@FANGPENG /e/jek_demo/jekyll-bootstrap (master)
# 然后在启动服务,ok啦
$ jekyll serve
Configuration file: e:/jek_demo/jekyll-bootstrap/_config.yml
Source: e:/jek_demo/jekyll-bootstrap
   Destination: e:/jek_demo/jekyll-bootstrap/_site
  Generating... done.
Server address: http://0.0.0.0:4000
  Server running... press ctrl-c to stop.

访问http://localhost:4000/就出现以下页面了:

参考:
1.win7下安装jekyll——在github上创建自己的博客

2.Invalid configuration. Please fix 'config.yml.'

3.Jekyll在github上构建免费的Web应用

四、下一步

1、jekyll基础

你可能感兴趣的:(安装)