deepin/ubuntu下搭建Jekyll环境

前端之家收集整理的这篇文章主要介绍了deepin/ubuntu下搭建Jekyll环境前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

最近用github搭建了个博客,正好也学习一下markdown语法,由于markdown写完后不是立即可见,所以每次写完文章都要经过在线调试,而在线调试就得上线文章,每次上线都得重复git add, git commit, git push这三步。

安装ruby

$ sudo apt install ruby

$ sudo apt-get install ruby-dev

设置国内ruby的源

$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
$ gem sources -l
$ sudo gem install rails

如果你使用 Gemfile 和 Bundle (例如:Rails 项目)

你可以用 Bundler 的 Gem 源代码镜像命令

$ bundle config mirror.https://rubygems.org https://gems.ruby-china.org

这样你不用改你的 Gemfile 的 source。

source 'https://rubygems.org/'
gem 'rails','4.1.0'

更多设置,请参考阿里巴巴的ruby镜像

安装部分依赖

ubuntu下需要自己安装nodejs,等一些其他的包(如果没安装下面的包,运行jekyll server会遇到ExecJS::RuntimeUnavailable错误)

$ sudo apt-get install python-software-properties  
$ sudo add-apt-repository ppa:chris-lea/node.js  
$ sudo apt-get update  
$ sudo apt-get install nodejs

或者使用NVM的安装方式来进行nodejs的安装

安装jekyll

$ sudo gem install jekyll
admin@admin-pc:~$ sudo gem install jekyll
Fetching: public_suffix-2.0.5.gem (100%)
Successfully installed public_suffix-2.0.5
Fetching: addressable-2.5.1.gem (100%)
Successfully installed addressable-2.5.1
Fetching: colorator-1.1.0.gem (100%)
Successfully installed colorator-1.1.0
Fetching: sass-3.4.23.gem (100%)
Successfully installed sass-3.4.23
Fetching: jekyll-sass-converter-1.5.0.gem (100%)
Successfully installed jekyll-sass-converter-1.5.0
Fetching: rb-fsevent-0.9.8.gem (100%)
Successfully installed rb-fsevent-0.9.8
Fetching: ffi-1.9.18.gem (100%)
Building native extensions.  This could take a while...
Successfully installed ffi-1.9.18
Fetching: rb-inotify-0.9.8.gem (100%)
Successfully installed rb-inotify-0.9.8
Fetching: listen-3.0.8.gem (100%)
Successfully installed listen-3.0.8
Fetching: jekyll-watch-1.5.0.gem (100%)
Successfully installed jekyll-watch-1.5.0
Fetching: kramdown-1.13.2.gem (100%)
Successfully installed kramdown-1.13.2
Fetching: liquid-3.0.6.gem (100%)
Successfully installed liquid-3.0.6
Fetching: mercenary-0.3.6.gem (100%)
Successfully installed mercenary-0.3.6
Fetching: forwardable-extended-2.6.0.gem (100%)
Successfully installed forwardable-extended-2.6.0
Fetching: pathutil-0.14.0.gem (100%)
Successfully installed pathutil-0.14.0
Fetching: rouge-1.11.1.gem (100%)
Successfully installed rouge-1.11.1
Fetching: safe_yaml-1.0.4.gem (100%)
Successfully installed safe_yaml-1.0.4
Fetching: jekyll-3.4.3.gem (100%)
Successfully installed jekyll-3.4.3
Parsing documentation for public_suffix-2.0.5
Installing ri documentation for public_suffix-2.0.5
Parsing documentation for addressable-2.5.1
Installing ri documentation for addressable-2.5.1
Parsing documentation for colorator-1.1.0
Installing ri documentation for colorator-1.1.0
Parsing documentation for sass-3.4.23
Installing ri documentation for sass-3.4.23
Parsing documentation for jekyll-sass-converter-1.5.0
Installing ri documentation for jekyll-sass-converter-1.5.0
Parsing documentation for rb-fsevent-0.9.8
Installing ri documentation for rb-fsevent-0.9.8
Parsing documentation for ffi-1.9.18
Installing ri documentation for ffi-1.9.18
Parsing documentation for rb-inotify-0.9.8
Installing ri documentation for rb-inotify-0.9.8
Parsing documentation for listen-3.0.8
Installing ri documentation for listen-3.0.8
Parsing documentation for jekyll-watch-1.5.0
Installing ri documentation for jekyll-watch-1.5.0
Parsing documentation for kramdown-1.13.2
Installing ri documentation for kramdown-1.13.2
Parsing documentation for liquid-3.0.6
Installing ri documentation for liquid-3.0.6
Parsing documentation for mercenary-0.3.6
Installing ri documentation for mercenary-0.3.6
Parsing documentation for forwardable-extended-2.6.0
Installing ri documentation for forwardable-extended-2.6.0
Parsing documentation for pathutil-0.14.0
Installing ri documentation for pathutil-0.14.0
Parsing documentation for rouge-1.11.1
Installing ri documentation for rouge-1.11.1
Parsing documentation for safe_yaml-1.0.4
Installing ri documentation for safe_yaml-1.0.4
Parsing documentation for jekyll-3.4.3
Installing ri documentation for jekyll-3.4.3
Done installing documentation for public_suffix,addressable,colorator,sass,jekyll-sass-converter,rb-fsevent,ffi,rb-inotify,listen,jekyll-watch,kramdown,liquid,mercenary,forwardable-extended,pathutil,rouge,safe_yaml,jekyll after 29 seconds
18 gems installed

如果上一步安装过程中没有安装rdoc,rdiscount,kramdown,jekyll-sitemap 等,可以执行下面步骤安装

$ sudo gem install kramdown  
$ sudo gem install rdoc  
$ sudo gem install rdiscount
$ sudo gem install jekyll-sitemap
admin@admin-pc:~$ sudo gem install kramdown
Successfully installed kramdown-1.13.2
Parsing documentation for kramdown-1.13.2
Done installing documentation for kramdown after 2 seconds
1 gem installed

admin@admin-pc:~$ sudo gem install rdoc
Fetching: rdoc-5.1.0.gem (100%)
Successfully installed rdoc-5.1.0
Parsing documentation for rdoc-5.1.0
Installing ri documentation for rdoc-5.1.0
Done installing documentation for rdoc after 10 seconds
1 gem installed

admin@admin-pc:~$ sudo gem install rdiscount
Fetching: rdiscount-2.2.0.1.gem (100%)
Building native extensions.  This could take a while...
Successfully installed rdiscount-2.2.0.1
Parsing documentation for rdiscount-2.2.0.1
Installing ri documentation for rdiscount-2.2.0.1
Done installing documentation for rdiscount after 0 seconds
1 gem installed

admin@admin-pc:~$ sudo gem install jekyll-sitemap
Fetching: jekyll-sitemap-1.1.1.gem (100%)
Successfully installed jekyll-sitemap-1.1.1
Parsing documentation for jekyll-sitemap-1.1.1
Installing ri documentation for jekyll-sitemap-1.1.1
Done installing documentation for jekyll-sitemap after 0 seconds
1 gem installed

上面步骤执行完后,本地的jekyll环境就搭建完成了,进入你博客的目录,运行下面的命令启动

可以从我的github上下载我现在使用的jekyll主题来作为自己的博客主题
github地址:https://github.com/sixtrees/sixtrees.github.com.git

admin@admin-pc:~$ ls
Android  Desktop    Downloads     Music     Snapshots  Steam                     Videos    WebstormProjects
ch13     Documents  IdeaProjects  Pictures  softs      Story-writer-linux64.zip  watchman
admin@admin-pc:~$ cd Documents/
admin@admin-pc:~/Documents$ ls
AwesomeProject
admin@admin-pc:~/Documents$ mkdir jekyll
admin@admin-pc:~/Documents$ cd jekyll/
admin@admin-pc:~/Documents/jekyll$ ls
admin@admin-pc:~/Documents/jekyll$ git clone https://github.com/sixtrees/sixtrees.github.com.git
正克隆到 'sixtrees.github.com'...
remote: Counting objects: 524,done.
remote: Total 524 (delta 0),reused 0 (delta 0),pack-reused 524
接收对象中: 100% (524/524),347.10 KiB | 31.00 KiB/s,完成.
处理 delta 中: 100% (301/301),完成.

进入到项目中,执行下面的命令

$ jekyll server

之后会有提示,访问http://0.0.0.0:4000就可以啦。

admin@admin-pc:~/Documents/jekyll/sixtrees.github.com$ jekyll server
Configuration file: /home/admin/Documents/jekyll/sixtrees.github.com/_config.yml
Configuration file: /home/admin/Documents/jekyll/sixtrees.github.com/_config.yml
            Source: /home/admin/Documents/jekyll/sixtrees.github.com
       Destination: /home/admin/Documents/jekyll/sixtrees.github.com/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
                    done in 2.371 seconds.
 Auto-regeneration: enabled for '/home/admin/Documents/jekyll/sixtrees.github.com'
Configuration file: /home/admin/Documents/jekyll/sixtrees.github.com/_config.yml
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.

访问

可以看到和我在github上托管的gitpages一样。

原文链接:https://www.f2er.com/ubuntu/352955.html

猜你在找的Ubuntu相关文章