[英]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 ),請執行以下操作:
git init
git remote add origin git@github.com:userName/userName.github.io.git
( UO ) 或git remote add origin git@github.com:userName/repositoryName.git
( P )jekyll new .
創建您的代碼庫baseurl: ''
( UO ) 或baseurl: '/repositoryName'
( P )jekyll build
將創建目標文件夾和構建站點。git checkout -b sources
( UO ) 或git checkout master
( P )git add -A
git commit -m "jekyll base sources"
提交你的源代碼git push origin sources
( UO ) 或git push origin master
( P ) 在適當的分支中推送你的源代碼cd _site
touch .nojekyll
,這個文件告訴 gh-pages 不需要構建git init
初始化存儲庫git remote add origin git@github.com:userName/userName.github.io.git
( UO ) 或git remote add origin git@github.com:userName/repositoryName.git
( P )git checkout master
( UO ) 或git checkout -b gh-pages
( P ) 將此存儲庫放在適當的分支上git add -A
git commit -m "jekyll first build"
提交你的站點代碼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
部署步驟(每次推送后):
_site
目錄中的自定義腳本script/cibuild
創建構建_site
將被推送到gh-pages
分支。.nojekyll
文件)參考:我的存儲庫https://github.com/armujahid/armujahid.me/正在使用這種方法使用 Travis CI 進行持續集成
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.