jekyll 博客安裝
為什么要用jekyll
jekyll
是一個簡單的免費的Blog生成工具,類似WordPress。但是和WordPress又有很大的不同,原因是jekyll只是一個生成靜態網頁的工具,不需要數據庫支持。但是可以配合第三方服務,例如Disqus。最關鍵的是jekyll可以免費部署在Github上,而且可以綁定自己的域名。
語言支持
1、ruby -v
查看你的機器是否安裝了ruby ,成功如下
ruby 2.3.7p456 (2018-03-28 revision 63024)
[universal.x86_64-darwin17]
2、gem install jekyll
RubyGems 是 Ruby 的一個包管理器,會下載 依賴文件,我執行的時候報錯看提示像環境變量的問題。
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.11.3/ext/ffi_c
3 sudo gem install jekyll
命令執行報錯
Building native extensions. This could take a while...
Successfully installed sassc-2.2.1
Fetching: jekyll-sass-converter-2.0.1.gem (100%)
ERROR: Error installing jekyll:
jekyll-sass-converter requires Ruby version >= 2.4.0.
解決方式 重新指定鏡像地址 更新gem
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
sudo gem update --system
重新安裝ruby
brew install ruby
執行完成之后需要手動執行 export
You may want to add this to your PATH.
ruby is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have ruby first in your PATH run:
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
For compilers to find ruby you may need to set:
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
4、執行完成之后查看 ruby -v
是否大於等於2.4版本
5、執行gem安裝Jekyll
安裝 Jekyll
6、zsh: command not found: jekyll
報錯
執行sudo gem install --user-install bundler jekyll
之后還是報錯如下:
WARNING: You don't have /Users/你的用戶名/.gem/ruby/2.6.0/bin in your PATH,
這個時候加入到path
中
export PATH=${PATH}:/Users/tonyyang/.gem/ruby/2.6.0/bin
此刻再執行jekyll -v
, 顯示成功。
7、跑到項目目錄底下執行 jekyll
報錯
19: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler.rb:107:in `setup'
18: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/runtime.rb:20:in `setup'
17: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/runtime.rb:108:in `block in definition_method'
16: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:226:in `requested_specs'
15: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:237:in `specs_for'
14: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:170:in `specs'
13: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:247:in `resolve'
12: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:744:in `converge_locked_specs'
11: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:744:in `each'
10: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/definition.rb:758:in `block in converge_locked_specs'
9: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git.rb:167:in `specs'
8: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/path.rb:100:in `local_specs'
7: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git.rb:200:in `load_spec_files'
6: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/path.rb:163:in `load_spec_files'
5: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/path.rb:126:in `expanded_path'
4: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git.rb:93:in `install_path'
3: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git.rb:225:in `revision'
2: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git/git_proxy.rb:64:in `revision'
1: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git/git_proxy.rb:192:in `find_local_revision'
/usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/bundler/source/git/git_proxy.rb:235:in `allowed_in_path': The git source git://github.com/flori/json.git is not yet checked out. Please run `bundle install` before trying to start your application (Bundler::GitError)
提示很清楚了要執行bundle install
命令。
8、jekyll new sss
重新創建一個名為sss的項目
Running bundle install in /Users/tonyyang/IdeaProjects/sss...
Bundler: Fetching gem metadata from https://gems.ruby-china.com/............
Bundler: Fetching gem metadata from https://gems.ruby-china.com/..
Bundler: Resolving dependencies...
Bundler: Using public_suffix 4.0.2
Bundler: Using addressable 2.7.0
Bundler: Using bundler 2.1.3
Bundler: Using colorator 1.1.0
Bundler: Using concurrent-ruby 1.1.5
Bundler: Using eventmachine 1.2.7
Bundler: Using http_parser.rb 0.6.0
Bundler: Using em-websocket 0.5.1
Bundler: Using ffi 1.11.3
Bundler: Using forwardable-extended 2.6.0
Bundler: Using i18n 1.7.0
Bundler: Using sassc 2.2.1
Bundler: Using jekyll-sass-converter 2.0.1
Bundler: Using rb-fsevent 0.10.3
Bundler: Using rb-inotify 0.10.1
Bundler: Using listen 3.2.1
Bundler: Using jekyll-watch 2.2.1
Bundler: Using kramdown 2.1.0
Bundler: Using kramdown-parser-gfm 1.1.0
Bundler: Using liquid 4.0.3
Bundler: Using mercenary 0.3.6
Bundler: Using pathutil 0.16.2
Bundler: Using rouge 3.14.0
Bundler: Using safe_yaml 1.0.5
Bundler: Using unicode-display_width 1.6.0
Bundler: Using terminal-table 1.8.0
Bundler: Using jekyll 4.0.0
Bundler: Using jekyll-feed 0.13.0
Bundler: Using jekyll-seo-tag 2.6.1
Bundler: Using minima 2.5.1
Bundler: Bundle complete! 6 Gemfile dependencies, 30 gems now installed.
Bundler: Use `bundle info [gemname]` to see where a bundled gem is installed.Following files may not be writable, so sudo is needed:
Bundler: /usr/local/lib/ruby/gems/2.6.0/bundler.lock
New jekyll site installed in /Users/tonyyang/IdeaProjects/sss
9、cd 到sss
項目目錄下執行jekyll serve
命令
Configuration file: /Users/tonyyang/IdeaProjects/sss/_config.yml
Source: /Users/tonyyang/IdeaProjects/sss
Destination: /Users/tonyyang/IdeaProjects/sss/_site
Incremental build: disabled. Enable with --incremental
Generating...
Jekyll Feed: Generating feed for posts
done in 0.517 seconds.
Auto-regeneration: enabled for '/Users/tonyyang/IdeaProjects/sss'
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.
顯示成功,通過http://localhost:4000/
訪問
以上就是jekyll搭建個人博客網站內容。