Walkthrough Jekyll

Welcome to another burden.cc

May 25, 2018 · 2 min

Welcome to another edition of “Let’s start from scratch”. Get a beer, because this time around there’s examples so you can follow along.

In this series of blog posts, we’ll build a Jekyll blog from scratch and use Github Pages as a stage. If you follow along, please be sure to switch out values for your own.

First we need to make sure Jekyll is installed…

$ gem install jekyll

Moving in

I’m starting with a clean git repository so I can take full advantage of Github. Scope it out: burden/burdendotcc.

$ jekyll new burdendotcc
$ cd burdendotcc
$ git init
$ git add .
$ git commit -m “Initial commit”

Next we’ll lock in Ruby version 2.5.3.

$ echo 2.5.3 > .ruby-version

Tell Gemfile about it by adding a line after source.

source "https://rubygems.org"
ruby RUBY_VERSION

Now for some plugins…

Update the :jekyll_plugins block in Gemfile.

group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.6"
  gem "jekyll-assets"
  gem "kramdown"
  gem "uglifier", "~> 3.2"
end

Update the plugins block in _config.yml.

plugins:
  - jekyll-feed
  - jekyll-assets
  - kramdown
  - uglifier

Setup Bundler and install the plugins.

$ gem install bundler
$ bundle install

Now we can get that asset pipeline going. Configure jekyll-assets by adding some lines to _config.yml

assets:
  sources:
  - _assets/vendor # for dependencies
  digest: true # cache busting
  compression: true # remove whitespace from css and js
  defaults:
    js: { integrity: false } # true on JEKYLL_ENV=production
    css: { integrity: false } # true on JEKYLL_ENV=production
    img: { integrity: false } # true on JEKYLL_ENV=production
  compress:
    css: true
    js: uglifier

Tell .gitignore not to commit the asset cache

.jekyll-metadata
.jekyll-cache

When building the site, Jekyll makes you choose whether to A) maintain a black list of files to exclude or B) specify a source directory. I find it to be more organized, safer, and overall much easier to just specify a source directory.

I also like switching the destination directory from _sites to www.

Tell .gitignore not to commit the destination directory.

.asset-cache
www

Add the following under # Build settings in _config.yml

# Build settings
source: src
destination: www
markdown: kramdown

Move all of the files.

$ mkdir src
$ mv index.md about.md 404.html _posts src

Finally we fire up that welcome page.

$ bundle exec jekyll serve

Save our progress and push the project files to the master branch on Github.

$ git add .
$ git commit -m "Adding welcome post"
$ git remote add origin git@github.com:burden/burdendotcc.git
$ git push -u origin master

In the next post we’ll setup Github Pages to use as a stage.

Current article

Welcome to another burden.cc