I recently upgraded this blog to Octopress 3, as part of rebuilding (and Docker-ifying) my blog Jekyll build environment. This post is a guide of my upgrade experience and to talk about various workarounds I needed to make to get everything working.
Introduction to Octopress 3
With Octopress 2, the paradigm I
used was to fork the canonical
Octopress Git repository and maintain all my posts and theme files as a branch
forked off of the Octopress "master" branch. I then periodically ran git merge
octopress/master
to pull upstream core Octopress infrastructure changes into
my custom branch.
As mentioned in the official "Octopress 3.0 Is Coming" announcement, there were various downsides to the Octopress 2 paradigm. The main pain-point revolves around how Octopress 2 is basically just the skeleton of a Jekyll blog that you need to fork and modify – which means that when you want to take upstream changes of the Octopress 2 infrastructure, you need to merge those upstream changes into your local forked branch and work through any merge-conflicts. Sometimes easy, sometimes time-consuming.
With Octopress 3, all of this has been re-thought so that your site is a Jekyll site first-and-foremost and all the extra Octopress "goodies" are delivered via gems which can be used as Jekyll plugins. That creates a nice clean separation between your site content versus the Jekyll site-building tools. Neat!
Octopress 3 is Dead, Long Live Octopress 3 …?
Side note: it's unclear what the future of Octopress 3 is.
Octopress 3 development was active and vibrant circa 2015, but all the activity in the Octopress plugin repositories seemed to tail-off towards the beginning of 2016. It's a shame, but I understand how these things sometimes go – priorities change, and life comes first.
I opted to embrace Octopress 3 as-is because I was a big Octopress 2 fan and I really like the Octopress 3 vision. Also, I wanted the small quality-of-life features which Octopress added above-and-beyond the default Jekyll scaffolding.
But I did run into some small bumps along the way – more on that later.
Setup Docker
I created a docker-compose.yml
file to compartmentalize Jekyll build
environment:
Some key points:
- Use the standard
jekyll/jekyll:latest
Docker image. - Use a persistent Docker volume as the
$BUNDLE_PATH
to avoid needing to re-download and re-install all theGemfile
gems for eachdocker-compose run
container.
Using Docker containers means everything is compartmentalized and that it's easy to bootstrap my blog build environment onto another machine. Containers for the win.
Setup a New (Octopress 3-Flavored!) Jekyll Site
Create a new directory for your brand-new Jekyll site:
Copy your docker-compose.yml
file into the new directory.
Use docker-compose run
to start a shell into a new Docker container:
Install the Octopress gem:
Use the octopress new
command to create a new Octopress-flavored Jekyll site:
(Tip: You'll need to pass the -f
flag to octopress new
because you're
trying to install into a directory which already exists)
Edit the Gemfile
(created during octopress new
) and minimally add the
baseline Jekyll and Octopress gem dependencies:
At this point, you have a brand-new empty Jekyll site with a few extra
Octopress-flavored bits (like the _templates
directory), and you can run
normal Jekyll commands like 'jekyll serve',
jekyll build
, etc.
Managing Jekyll Plugin Gems
Jekyll supports several ways of managing gem-based plugins.
I opted to manage all my gem plugins via a Bundler group in the Gemfile
file.
This just seemed the most straight-forward approach. It also seemed like a good
idea to track both the Gemfile
file and counterpart Gemfile.lock
file via
source-control (e.g. Git), but your mileage may vary.
There are several neat Octopress 3 gem plugins, but I found that several of the
plugins didn't work out-of-the-box with Jekyll 3.x (because most of the
plugins haven't been maintained in over a year now). But thanks to the
community-effect of GitHub, several other folks have fixed the Jekyll
incompatibility problems and submitted pull requests. You can install the
patched version of the various Octopress 3 gems by specifying an explicit
git:
remote URL (and the specific branch:
) for that particular gem in your
Gemfile
.
Here is the final Gemfile
I ended-up with, with various patched Octopress
gems:
Migrating Content
You'll need to copy over whatever parts you need from your old Octopress 2 site to your new Octopress 3 site:
- Copy all your posts:
source/_posts
->_posts
- Copy all your other pages
- Copy all your images:
source/images
->images
- Copy any theme files:
source/_includes
->_includes
, etc, etc.
Installing a Theme
The original Octopress 2 theme was baked into the Octopress 2 git branch.
You could probably migrate over the old Octopress 2 theme from your old Octopress 2 site, but now that we're using plain-vanilla Jekyll 3 that means we can use any of the plethora of Jekyll-based themes. So I went hunting for a new theme.
I ended-up choosing the Pixyll theme because it was clean and modern.
I "installed" the Pixyll theme by:
- Cloning the Pixyll theme from its GitHub repo to a separate directory.
- Manually copying over the files I wanted from the Pixyll directory into my Octopress 3 site.
- Tracking the pristine Pixyll theme files in a baseline commit.
- Personalizing the theme files as I wanted.
I opted to create a "baseline" commit of the Pixyll theme (along with making
note of what Git revision # from the Pixyll repo I was forking at) to (in
theory) make it easier to take and review upstream changes to the Pixyll git
branch: create a local Git branch off that baseline commit, copy in any
upstream changes to the Pixyll theme, and then git merge
forward onto my
local master
branch and work through any merge conflicts.
Here are some of the customizations & personalizations I made along the way:
- Updated
_config.yml
to set varioussite
flags which the Pixyll theme respects. - Updated
_includes/footer.html
to include my name and copyright. - Updated
_includes/head.html
to add the{% css_asset_tag %}
Liquid tag, which was needed to get theoctopress-solarized
plugin to take effect (via theoctopress-asset-pipeline
plugin). - Various tweaks to CSS styling.
Resources
Here are some helpful posts which laid out the vast majority of the migration process:
- http://samwize.com/2015/09/30/migrating-octopress-2-to-octopress-3/
- https://dgmstuart.github.io/blog/2016/01/22/migrating-from-octopress-2-to-3/
- http://www.dracotorre.com/blog/site-updated-octopress-3/
Happy upgrading!