Github Pages Tips:
Github Pages always complie jekyll with--safeoption that will
disable plugins but some plugin can work with Github Pages.
List of Jekyll Plguins that working on Github > Pages
To avoid this --safe option to be powerful jekyll, you need to build your jelyll somewhere else and commit your static page to main or gh-page branch.
We can automate build jekyll with Travis-CI
that store your jekyll file in jekyll branch when push to github that
will trig to Travis to build and deploy static page back to your main
branch to publish your contents. you should read previous blog about
jekyll and travis
.travis.yml always keep > /dev/null 2>&1 to avoid your tokens display on logs or you can remove for debugging git push.verified email for trigger update contents.feed.xml on JekyllDefault
branch on your Github repository settings that will use your
Default branch to hosting your page.Verified by Mildronize
Create jekyll branch for development
$ git branch jekyll
Clear your main or gh-page branch to blank
$ git rm *
Build
only if .travis.yml is present on your travis repository settings.Checkout jekyll branch and create .travis.yml then edit GH_REF
and TARGET_BRANCH to your own
$ git checkout jekyll
.travis.yml
sudo: false
language: ruby
rvm:
- 2.2
branches:
only:
- jekyll
script:
- bundle exec jekyll build
- bundle exec htmlproofer ./_site --disable-external
after_success:
- git clone https://$GH_REF
- cd $(basename ${GH_REF%.git})
- git config user.name "Travis-CI"
- git config user.email ${EMAIL}
- rsync -az --delete --exclude '.git*' ../_site/ .
- touch .nojekyll
- git add -A .
- git commit -m "Generated Jekyll Site by Travis CI - ${TRAVIS_BUILD_NUMBER}"
- git push -f "https://${DEPLOY_KEY}@${GH_REF}" ${TARGET_BRANCH} > /dev/null 2>&1
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
- GH_REF: github.com/ibotdotout/ibotdotout.github.io.git
- TARGET_BRANCH: master
repo that enough.Install Travis Gem on your machine for encryption sensitive data
$ gem install travis
Encrypt your EMAIL and DEPLOY_KEY
# --add opton will automated add sescure data to your .travis.yml
# edit verifiedemail to your github email account
$ travis encrypt EMAIL=verifiedemail --add
# edit githubtoken to your github personal access tokens
$ travis encrpy DEPLOY_KEY=githubtoken --add
Commit jekyll branch
$ git add -A
$ git commit -m "Create Jekyll branch for build jekyll with Travis"
Push to jekyll branch to Github repository and wait
$ git push origin jekyll
# Don't care warnning about main/gh-page branch that local repository out of date
I use develop branch as jekyll and I’m lazy to change but I recommend to use jekyll branch should be better.
# config local git repo to push only current active branch
$ git config push.default simple