Skip to content

Instantly share code, notes, and snippets.

@mdrmike
Last active March 17, 2016 05:20
Show Gist options
  • Save mdrmike/f59b3c92d0c403285cd3 to your computer and use it in GitHub Desktop.
Save mdrmike/f59b3c92d0c403285cd3 to your computer and use it in GitHub Desktop.
Jekyll Gemfile for github pages and Travis-CI

Use this Gemfile with bundler to quickly setup Jekyll for use with Github Pages and optionally Travis-CI

Quick Download Command

curl -O https://gist.githubusercontent.com/mdrmike/f59b3c92d0c403285cd3/raw/dee8f1de2b1ce312b357478974806a6cab5b9fbe/Gemfile

Requirements

Optional

Instructions

  1. Setup a new Jekyll website
  2. Add this Gemfile to the (root of the) website
  3. Run bundle install to have Bundler install gems for github pages

Setup Example

These commands will create a new Jekyll website called j.demo. Copy and paste the first line in a terminal, and optionally modify the SITE variable to your liking. Then copy, paste, and run the rest of the commands.

SITE=j.demo                   # URL or directory for Jekyll

mkdir -p ~/www/               # Make www folder if needed
jekyll new ~/www/${SITE}      # Create new Jekyll site
cd ~/www/${SITE}              # CD folders into new site
                              # Download Gemfile (next line)
curl -O https://gist.githubusercontent.com/mdrmike/f59b3c92d0c403285cd3/raw/dee8f1de2b1ce312b357478974806a6cab5b9fbe/Gemfile
bundle install                # Use [Bundler](http://bundler.io/) to setup exactly same as Github Production
atom .                        # Open Atom.io editor (optional)
bundle exec jekyll serve      # Start Jekyll internal webserver (optional)

Cusomtize for Github

You'll need to modify _config.yml and template files in _layouts per these instructions.

Summary

_config.yml

github:  
  url: "YOURURL"  

_includes/YOURFILE

<!-- Useful for styles with static names... -->
<link href="{{ site.github.url }}/path/to/css.css" rel="stylesheet">
<!-- and for documents/pages whose URL's can change... -->
<a href="{{ page.url | prepend: site.github.url }}">{{ page.title }}</a>

Teardown Example

Similar to above, these commands will cleanup the site.

SITE=j.demo                   # URL or directory for Jekyll
cd && rm -Rf ~/www/${SITE}    #jekyll #destroy-website #talk-jekyll
# Gemfile to setup Jekyll for use with Github pages hosting
# Based on
# - https://jekyllrb.com/docs/github-pages/
# - https://jekyllrb.com/docs/continuous-integration/
source 'https://rubygems.org'
require 'json'
require 'open-uri'
versions = JSON.parse(open('https://pages.github.com/versions.json').read)
gem 'github-pages', versions['github-pages']
## Optional setup for Travis-CI
#gem 'html-proofer' # useful for Travis-CI
#gem 'scss_lint' # useful for Travis-CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment