最近用github搭建了个博客,正好也学习一下markdown语法,由于markdown写完后不是立即可见,所以每次写完文章都要经过在线调试,而在线调试就得上线文章,每次上线都得重复git add, git commit, git push这三步。
安装ruby
@H_502_5@$ sudo apt install ruby $ sudo apt-get install ruby-dev设置国内ruby的源
@H_502_5@$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/ @H_502_5@$ gem sources -l @H_502_5@$ sudo gem install rails如果你使用 Gemfile 和 Bundle (例如:Rails 项目)
你可以用 Bundler 的 Gem 源代码镜像命令。
@H_502_5@$ bundle config mirror.https://rubygems.org https://gems.ruby-china.org这样你不用改你的 Gemfile 的 source。
@H_502_5@source 'https://rubygems.org/' gem 'rails','4.1.0'更多设置,请参考阿里巴巴的ruby镜像
安装部分依赖
ubuntu下需要自己安装nodejs,等一些其他的包(如果没安装下面的包,运行jekyll server
会遇到ExecJS::RuntimeUnavailable
错误)
或者使用NVM
的安装方式来进行nodejs的安装
安装jekyll
@H_502_5@$ sudo gem install jekyll @H_502_5@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 等,可以执行下面步骤安装
@H_502_5@$ sudo gem install kramdown $ sudo gem install rdoc $ sudo gem install rdiscount $ sudo gem install jekyll-sitemap @H_502_5@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
进入到项目中,执行下面的命令
@H_502_5@$ jekyll server之后会有提示,访问http://0.0.0.0:4000
就可以啦。
访问
可以看到和我在github上托管的gitpages一样。