Window下Jekyll本地服务器部署与测试

Window下Jekyll本地服务器部署与测试

1 安装Ruby

下载并安装Ruby,下载地址为:Ruby

打开cmd,输入以下命令,确认是否安装成功:

$ ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32]

2 安装jekyll

gem与ruby一块安装生效,打开cmd命令行程序,输入以下命令:

$ gem install jekyll

然后输入创建博客的命令:

$ cd blogfolder
$ jekyll new testblog 

进入testblog目录,输入:

$ cd testblog
$ jekyll server
Configuration file: D:/Blog/website/testblog/_config.yml
            Source: D:/Blog/website/testblog
       Destination: D:/Blog/website/testblog/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
       Jekyll Feed: Generating feed for posts
                    done in 0.579 seconds.
 Auto-regeneration: enabled for 'D:/Blog/website/testblog'
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.

打开浏览器输入:

http://localhost:4000/


3 使用已有模板

进入下载到的已有jekyll模板目录:

$ cd templatefolder

取2中testblog目录下的Gemfile与Gemfile.lock,复制或替换templatefolder目录下相应文件,原Gemfile文件里的plugin之类配置需要保留,如:

group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.12"
  gem "jekyll-paginate"
  gem "jekyll-sitemap"
end

运行以下命令:

$ jekyll server

浏览器打开http://localhost:4000/即可,若出现以下错误

D:/Ruby27-x64/lib/ruby/2.7.0/bundler/spec_set.rb:86:in `block in materialize': Could not find public_suffix-4.0.5 in any of the sources (Bundler::GemNotFound)

可在命令行中输入:

$ gem install public_suffix --version 4.0.5

参考

[1] Github+Jekyll 搭建个人网站详细教程


Tags: Jekyll Vistied:
Share: Twitter Facebook LinkedIn