目錄:
安裝jekyll-mac下放棄因為 Jekyll 是基於 Ruby 的靜態網頁生成系統,因此我們首先得安裝 Ruby 環境,在 Mac 下我們可以使用的 Homebrew 來進行安裝。如果是其他作業系統,可以去參考 Ruby 官方安裝文件進行安裝。
brew install rubygem install jekyll bundler
嘗試過以下都不行:
brew reinstall ruby
brew install rbenv
gem install --user-install bundler jekyll
sudo gem install jekyll
sudo gem update --system
gem install --user-install jekyllWARNING: You don't have /Users/virhuiaivirhuiai/.gem/ruby/2.6.0/bin in your PATH, gem executables will not run.export PATH="/Users/virhuiaivirhuiai/.gem/ruby/2.6.0/bin:$PATH"
。。。放棄
安裝jekyll-Dockerjekyll只是用來輔助寫作的,不想多研究,找到Docker下的相關映象:
# 搜尋下docker search jekyll
docker pull jekyll/jekyll:4.0docker pull jekyll/minimal:4.0docker pull jekyll/builder:4.0
可以選用上面的一個,一般選第一個標準版本就好,它的GitHub上的說明:
jekyll/jekyll: Default image.jekyll/minimal: Very minimal image.jekyll/builder: Includes tools.The standard images (jekyll/jekyll) include a default set of “dev” packages, along with Node.js, and other stuff that makes Jekyll easy. It also includes a bunch of default gems that the community wishes us to maintain on the image.
The minimal image skips all the extra gems, all the extra dev dependencies and leaves a very small image to download. This is intended for people who do not need anything extra but Jekyll.
The builder image comes with extra stuff that is not included in the standard image, like lftp, openssh and other extra packages meant to be used by people who are deploying their Jekyll builds to another server with a CI.
執行容器映象的使用說明中寫:
docker run --rm \ --volume="$PWD:/srv/jekyll" \ -it jekyll/jekyll:4.0 \ jekyll build
由於我們還沒有建立過,所以修改下改用:
# 進入本地的目錄cd /Users/virhuiaivirhuiai/Documents/virhuiai-github/
# 執行容器docker run --name my-jekyll \ -p 4000:4000 \ --volume="$PWD:/srv/jekyll" \ -it jekyll/jekyll:4.0 \ /bin/sh
-p命令是為了方便後面直接在容器中執行,指定了埠。
生成jekyll new pages
這會在當前目錄下建立一個 pages 目錄,裡面包含一個示例的網站
因為沒裝tree,切到宿主機到相應的目錄下檢視下結構:
構建切換到 pages 目錄下,構建剛剛生成的網站:
jekyll build
預設會將網站生成到 ./_site 目錄下,生成目錄可以透過配置檔案 ./_config.yml或命令列引數 --destination 設定:
virhuiaivirhuiai@virhuiaideMacBook-Pro pages % ls404.html Gemfile.lock _config.yml _site index.markdownGemfile README.md _posts about.markdown
本地預覽
將網站執行起來,在本地進行預覽:
jekyll server
然後可以在瀏覽器中 http://127.0.0.1:4000 來訪問,顯示如下介面
git新增_site到忽略.
提交前看了下,/.jekyll-cache/Jekyll/Cache/應該也可以加入忽略。
/_site//.idea//.jekyll-cache/Jekyll/Cache/