How do I configure GitHub to use non-supported Jekyll site plugins?
Asked Answered
H

2

23

I just created a great gallery for my Jekyll blog which builds perfectly on my localhost:4000. However, GitHub pages doesn't support the Jekyll Gallery Generator plug-in I am using: https://github.com/ggreer/jekyll-gallery-generator

I read about the alternative method of hosting Jekyll on a traditional host using FTP (uploading the _site directory) http://jekyllrb.com/docs/deployment-methods/ However, rather than reconfigure my entire site and hosting, It would be great if GitHub Pages could be used somehow even though I'm using a non-supported plugin.

What is a workaround for this?

Heighttopaper answered 31/1, 2015 at 7:18 Comment(0)
V
48

Depending if you deal with a User/Organization (UO) site or a Project site (P), do :

  1. from your working folder git init
  2. git remote add origin [email protected]:userName/userName.github.io.git (UO) or git remote add origin [email protected]:userName/repositoryName.git (P)
  3. jekyll new . creates your code base
  4. in _config.yml, set the baseurl parameter to baseurl: '' (UO) or baseurl: '/repositoryName' (P)
  5. in .gitignore add _site, it will be versioned in the other branch
  6. jekyll build will create the destination folder and build site.
  7. git checkout -b sources (UO) or git checkout master (P)
  8. git add -A
  9. git commit -m "jekyll base sources" commit your source code
  10. git push origin sources (UO) or git push origin master (P) push your sources in the appropriate branch
  11. cd _site
  12. touch .nojekyll, this file tells gh-pages that there is no need to build
  13. git init init the repository
  14. git remote add origin [email protected]:userName/userName.github.io.git (UO) or git remote add origin [email protected]:userName/repositoryName.git (P)
  15. git checkout master (UO) or git checkout -b gh-pages (P) put this repository on the appropriate branch
  16. git add -A
  17. git commit -m "jekyll first build" commit your site code
  18. git push origin master (UO) or git push origin gh-pages (P)

You now have something like Octopress does. Look at their rake file, there are some nice comments inside.

Venturesome answered 31/1, 2015 at 13:37 Comment(7)
Thanks David, great answer! My site is now running the gallery with the workflow you described: raisingthelittleone.com I do want to mention, however, that if you are using a custom domain (such as I am) even the Project Pages baseurl stays as a blank string.Heighttopaper
Thanks David. It's an amazing step forward in life. Baby.create!(name: "Luna") =DHeighttopaper
this is a great detailed answer. but in step 15, case UO, you don't actually have to git checkout master since you'll be automatically this branchDesdemona
if you have this setup, how do you keep the master sync with sources folder?Hoist
are you using two .gitignores here? one for each branch?Vipul
@HarryMoreno one .gitignore for me.Venturesome
THANK YOU, you saved my day!Fiasco
N
4

Better way is to configure Travis to automate deployment of jekyll with non-supported plugins. Follow Travis getting started guide to enable Travis for your repo.

Create script/cibuild with the following content

#!/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

Create .travis.yml with the following content (modify as required)

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

Deployment steps (after every push):

  1. Build will be created using our custom script script/cibuild in _site directory
  2. _site will be pushed to gh-pages branch.
  3. github pages will serve site as it is without building it again (because of .nojekyll file)

Reference: My repository https://github.com/armujahid/armujahid.me/ is using this method for continuous integration using Travis CI

Normand answered 21/7, 2018 at 9:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.