Jekyll
介紹Jekyll
是將純文本轉化爲靜態網站和博客的項目。官網 描述是這樣的:html
`Jekyll` 是一個簡單的博客形態的靜態站點生產機器。它有一個模版目錄,其中包含原始文本格式的文檔,經過 `Markdown` (或者 `Textile`) 以及 `Liquid` 轉化成一個完整的可發佈的靜態網站,你能夠發佈在任何你喜好的服務器上。`Jekyll` 也能夠運行在 `GitHub Page` 上,也就是說,你可使用 `GitHub` 的服務來搭建你的項目頁面、博客或者網站,並且是徹底免費的。
複製代碼
Jekyll
安裝安裝 Jekyll
是很是簡單的,可是事先你必須作好一些準備工做,確保你的機器上配置了windows
注意:在 windows 下使用 Jekyll,你可使用 Running Jekyll on Windows網站
RubyGems
安裝 Jekyll
安裝 Jekyll
的最好方式就是使用 RubyGems
. 你只須要打開終端輸入如下命令就能夠安裝了:ui
sudo gem install jekyll
複製代碼
全部的 Jekyll 的 gem 依賴包都會被自動安裝,因此你徹底不用去擔憂。若是你在安裝中碰到了問題.spa
注意:
Mac
須要安裝Xcode
和Command-Line Tools
了。下載方式Preferences → Downloads → Components
。code
打開終端找到本身喜歡的目錄執行regexp
jekyll new projectName[項目的名稱]
複製代碼
終端指向剛纔新初始化的項目目錄下,而後執行
jekyll server
複製代碼
正常狀況下會輸出以下內容
Configuration file: /Users/[用戶名]/StudyCloud/Blog/myblog/_config.yml
Source: /Users/[用戶名]/StudyCloud/Blog/myblog
Destination: /Users/[用戶名]/StudyCloud/Blog/myblog/_site
Incremental build: disabled. Enable with --incremental
Generating...
done in 0.382 seconds.
Auto-regeneration: enabled for '/Users/lane/StudyCloud/Blog/myblog'
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.
複製代碼
啓動的服務是監聽 4000
端口的。
若是是異常狀況,可能會輸出以下內容
/usr/local/Cellar/ruby/2.4.3_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler (LoadError)
from /usr/local/Cellar/ruby/2.4.3_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/jekyll-3.6.2/lib/jekyll/plugin_manager.rb:48:in `require_from_bundler'
from /usr/local/lib/ruby/gems/2.4.0/gems/jekyll-3.6.2/exe/jekyll:11:in `<top (required)>'
from /usr/local/bin/jekyll:23:in `load'
from /usr/local/bin/jekyll:23:in `<main>'
lanedeMacBook-Pro:myblog [用戶名]$ gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
複製代碼
若是異常狀況和這個一致,那麼問題就好解決了。
一、第一句話是說 bundler
這個包沒有找到。既然沒有找到那就安裝一個,執行命令 sudo gem install bundler
.
二、安裝完後,火燒眉毛的執行了一下 jekyll server
又發現報錯
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/resolver.rb:289:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'minima (~> 2.0)' in any of the gem sources listed in your Gemfile. (Bundler::GemNotFound)
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/resolver.rb:257:in `each'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/resolver.rb:257:in `verify_gemfile_dependencies_are_found!'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/resolver.rb:48:in `start'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/resolver.rb:22:in `resolve'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/definition.rb:257:in `resolve'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/definition.rb:170:in `specs'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/definition.rb:237:in `specs_for'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/definition.rb:226:in `requested_specs'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:108:in `block in definition_method'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:20:in `setup'
from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler.rb:107:in `setup'
from /usr/local/lib/ruby/gems/2.4.0/gems/jekyll-3.6.2/lib/jekyll/plugin_manager.rb:50:in `require_from_bundler'
from /usr/local/lib/ruby/gems/2.4.0/gems/jekyll-3.6.2/exe/jekyll:11:in `<top (required)>'
from /usr/local/bin/jekyll:23:in `load'
from /usr/local/bin/jekyll:23:in `<main>'
複製代碼
三、這報錯愈來愈可怕了。雖然可怕可是總有解決的辦法,繼續執行 bundle update
四、命令執行完後,再執行 bundle exec jekyll serve
或者 jekyll serve
就 OK 了。