簡體   English   中英

如何配置 GitHub 以使用不受支持的 Jekyll 站點插件?

[英]How do I configure GitHub to use non-supported Jekyll site plugins?

我剛剛為我的 Jekyll 博客創建了一個很棒的畫廊,它完美地構建在我的 localhost:4000 上。 但是,GitHub 頁面不支持我使用的 Jekyll Gallery Generator 插件: https : //github.com/ggreer/jekyll-gallery-generator

我閱讀了使用 FTP 在傳統主機上托管 Jekyll 的替代方法(上傳 _site 目錄) http://jekyllrb.com/docs/deployment-methods/但是,與其重新配置我的整個站點和托管,不如說它會很棒如果 GitHub Pages 可以以某種方式使用,即使我使用的是不受支持的插件。

什么是解決方法?

取決於您處理的是用戶/組織 ( UO ) 站點還是項目站點 ( P ),請執行以下操作:

  1. 從你的工作文件夾git init
  2. git remote add origin git@github.com:userName/userName.github.io.git ( UO ) 或git remote add origin git@github.com:userName/repositoryName.git ( P )
  3. jekyll new . 創建您的代碼庫
  4. _config.yml 中,將baseurl參數設置為baseurl: '' ( UO ) 或baseurl: '/repositoryName' ( P )
  5. .gitignore添加_site ,它將在另一個分支中進行版本控制
  6. jekyll build將創建目標文件夾和構建站點。
  7. git checkout -b sources ( UO ) 或git checkout master ( P )
  8. git add -A
  9. git commit -m "jekyll base sources"提交你的源代碼
  10. git push origin sources ( UO ) 或git push origin master ( P ) 在適當的分支中推送你的源代碼
  11. cd _site
  12. touch .nojekyll ,這個文件告訴 gh-pages 不需要構建
  13. git init初始化存儲庫
  14. git remote add origin git@github.com:userName/userName.github.io.git ( UO ) 或git remote add origin git@github.com:userName/repositoryName.git ( P )
  15. git checkout master ( UO ) 或git checkout -b gh-pages ( P ) 將此存儲庫放在適當的分支上
  16. git add -A
  17. git commit -m "jekyll first build"提交你的站點代碼
  18. git push origin master ( UO ) 或git push origin gh-pages ( P )

你現在有像Octopress那樣的東西。 看看他們的 rake 文件,里面有一些不錯的評論。

更好的方法是配置 Travis 以使用不受支持的插件自動部署 jekyll。 按照Travis 入門指南為您的存儲庫啟用 Travis。

使用以下內容創建script/cibuild

#!/usr/bin/env bash
set -e # halt script on error

bundle exec jekyll build
touch ./_site/.nojekyll # this file tells gh-pages that there is no need to build

使用以下內容創建.travis.yml (根據需要修改)

language: ruby
rvm:
- 2.3.3

before_script:
 - chmod +x ./script/cibuild # or do this locally and commit

# Assume bundler is being used, therefore
# the `install` step will run `bundle install` by default.
script: ./script/cibuild

# branch whitelist, only for GitHub Pages
branches:
  only:
  - master

env:
  global:
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true # speeds up installation of html-proofer

sudo: false # route your build to the container-based infrastructure for a faster build

deploy:
  provider: pages
  skip_cleanup: true
  keep-history: true
  local_dir: _site/  # deploy this directory containing final build
  github_token: $GITHUB_API_KEY # Set in travis-ci.org dashboard
  on:
    branch: master

部署步驟(每次推送后):

  1. 將使用我們在_site目錄中的自定義腳本script/cibuild創建構建
  2. _site將被推送到gh-pages分支。
  3. github 頁面將按原樣為站點提供服務,而無需再次構建它(因為.nojekyll文件)

參考:我的存儲庫https://github.com/armujahid/armujahid.me/正在使用這種方法使用 Travis CI 進行持續集成

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM