Blogging with Octopress

by Jeremy D. Frens on April 27, 2015


As I mentioned in my previous post, I wanted to move my blog off of Blogspot/Blogger. I want a blogging solution that allows me to edit my posts in my own editor, not the browser. Several months back, I restarted the blog with Octopress 2.x, and while Octopress has a lot of cool features, it uses git a little too much.1 I had been thinking that I might switch to using just a plain old Jekyll site.

But first I gave Octopress another chance and immediately discovered a blog post on the home page: “Octopress 3.0 Is Coming”. I realized everything was going to be okay when I read this: “The first, and most obvious flaw, is that Octopress is distributed through Git. I want to punch through a wall when I think about users wrestling with merge conflicts from updating their sites. It’s absurd.”

Octopress 3.0 is a complete rewrite. It is gem based. Yay!

This post documents what I did to get this blog up and running. It is a rather dry account of what I did, not necessarily in chronological order. Clarifications and justifications are in footnotes.

Possibly important system information

I’m not going to tell you how to get these installed:

  • Ruby 2.2.2
  • Latest version of Pow (optional)
  • powder gem version 0.3.0 (even more optional)

The first two links have the documentation you need to get your own blog started with Octopress 3.0. The others add more features.

Jekyll

First, I got a Jekyll site going:

% gem install jekyll
% jekyll new blogging-during-recess
% cd blogging-during-recess

Octopress

I created a Gemfile in the root of the Jekyll site:2

source 'https://rubygems.org'

gem "jekyll"
gem "pry-byebug"

group :jekyll_plugins do
  gem 'octopress', '~> 3.0.0.rc'
end

The first post

% octopress new post 'Something something something darkside'

This command spits out the name of the file it created, and I filled it with some very simple content.

Seeing the site

% jekyll server

I opened the URL that this command printed to the console, and voila!

POW!

Pow is quite optional, but I like it. Skip this section if you’re happy with the Jekyll server.

“Get your Jekyll site working with pow” got me started. I added this to my Jekyll plugins in the Gemfile:

group :jekyll_plugins do
  # ...
  gem 'rack-jekyll'
end

Then I created a config.ru:3

require 'safe_yaml'
require 'rack/jekyll'

run Rack::Jekyll.new

Then I linked the site into Pow:

% powder link

Instead of running the server, I built the site (continuously):4

% jekyll build --watch

Site data

I edited _config.yml with my blog’s name, base URL, and anything else it asked for. The file is well documented (and pretty obvious what it wants), so I’m not going to copy it into this post.

Theme

I’m sticking with the default Jekyll theme for now.5

Code blocks

My code blocks weren’t recognized as blocks, and I wanted to use the light Solarized theme. So I added two more gems as Jekyll plugins to the Gemfile:

group :jekyll_plugins do
  # ...
  gem 'octopress-codefence'
  gem 'octopress-solarized'
end

To use the light Solarized theme, I needed a config file:

% octopress ink copy octopress-solarized --config-file

I edited the _plugins/octopress-solarized/config.yml which was just created:

style: light

I also added this to _includes/head.html:6

{% css_asset_tag %}

RSS/Atom feed

I used Octopress Feeds to generate an Atom feed.

group :jekyll_plugins do
  # ...
  gem 'octopress-feeds'
end

I added two entries to _config.yml:

name: Blogging During Recess
author: Jeremy D. Frens

The default Jekyll template already had a link to the feed in the head element, so I did not add the Liquid call to feeds in _includes/head.html as the Octopress Feeds gem suggests.7 That template also created a menu for the header which awkwardly included the feed file, so I modified that menu in _includes/header.html:

<div class="trigger">
  <a class="page-link" href="{{ '/about' | prepend: site.baseurl }}">About</a>
</div>

Deploy!

We get Octopress Deploy for free with Octopress, so I added nothing to the Gemfile.

I generated a deploy configuration for rsync (my chosen deployment strategy):

% octopress deploy init rsync

My plan was to deploy locally to try it out, so I changed just two values in the default configuration:

remote_path: /tmp/blogging
# ...
exclude:
  - Gemfile
  - config.ru
  - tmp

Then I deployed:

% octopress deploy

I’m using Site44 to publish this website, so I just had to change the remote_path to point into my Dropbox folder, and I deploy locally just fine.

Thoughts

Octopress 3.0pre and its gems seem to be very workable right now. The Octopress Deploy gem had two bugs in it and didn’t support an array of files for the exlude option. Long story short, version 1.2.1 of that gem is courtesy of me.

The biggest issue is documentation, but there’s more than enough to one started with Octopress 3.0.

Footnotes

  1. Yes, it is very possible to use git too much.

  2. Remember to run bundle install whenever the Gemfile is changed.

  3. I found that requiring safe_yaml was necessary; otherwise the constant YAML was undefined for the rack-jekyll gem. There may be a better solution for this.

  4. I’ll admit that having to run this command kind of negates the benefits of running the blog through Pow. I wonder if I could get Pow to do the watching for me…

  5. The Octopress Genesis theme is in alpha, and I’m not keen on debugging templates, Liquid, HTML, SASS, CSS, and YAML. I may try this later, and if I do, I’ll blog about it then.

  6. If I were using an Octopress theme, not the default Jekyll theme, the CSS asset tag would already be in the theme.

  7. When I added a call to feeds in _includes/head.html, it generated a link tag with an incomple URL in it (missing a .xml).

blogging tooling