arrow-left arrow-right brightness-2 chevron-left chevron-right facebook-box facebook loader magnify menu-down rss-box star twitter-box twitter white-balance-sunny window-close
Multiple Octopress blogs, one Amazon S3 bucket
2 min read

Multiple Octopress blogs, one Amazon S3 bucket

Because of work I had to take a week off from this whole migration thing (I was in DC without my personal machine), but I’m slowly getting back on the neckbeard wagon. I’m still debating between Squarespace and Octopress, and along the way I’m basically just building up solutions for both platforms, so my site is kind of mirrored three ways right now.

Github Pages is a non-starter

A couple of days ago I concluded that hosting Octopress at Github Pages probably wasn’t an option for me; I need to run both my regular blog and photoblog, and as far as I can tell there’s no way to put a repository within a sub-directory of another repository, which I’d need to do if I wanted the photoblog to reside at /photos.

You might be thinking (but likely not!), “Hey, dumb shit, why don’t you keep a single Octopress instance and use categories to distinguish the two blogs?” Sure, that’s a great option, but for the fact that Octopress doesn’t support pagination of category pages (and I’d want that for the photoblog). Sure, it can be hacked together (see also), but it’s not pretty, and adds a layer of complexity to the system that, frankly, I’m trying to get away from.

Another option might be to insert some extra stuff into the YAML Front Matter of individual blog posts, and then if/else around them in the template code, but I think that could get a little hairy, especially if I want to style the photoblog a lot differently than the regular blog.

Amazon S3

As some of you know, you can host static websites with Amazon S3. The initial setup is relatively painless (I didn’t even have an [Amazon Web Services account](Amazon Web Services account) before getting all of this working in an evening), though pushing your Octopress files to the S3 bucket can be a little tricky.

The basic steps are this:

  1. Install s3cmd, which is a CLI tool for interfacing with Amazon S3.

  2. In your Octopress installation, modify Rakefile to include a deploy_default = s3cmd line and an s3_bucket = name of bucket line.

  3. Add the following code to Rakefile:

    task :s3cmd do
    puts Deploying to Amazon S3 [#{s3_bucket}]
    ok_failed system(s3cmd sync --acl-public --reduced-redundancy public/* s3://#{s3_bucket}/)
    end

That’s all you need to start pushing your first blog to Amazon S3. To get an additional blog working within a subdirectory of the same bucket, you need to repeat the above steps from within the second blog’s Octopress installation, and then add the subdirectory you want to the code in step 3, like so:

ok_failed system(s3cmd sync --acl-public --reduced-redundancy public/* s3://#{s3_bucket}/SUBDIR/)

Then, in _config.yml, you’ll want to add the sub-directory name to the url and permalink variables (assuming you want the permalinks for this blog to include the subdirectory). Finally, you’ll want to leave root set to “/”.

That’s it—two blogs, one bucket.

You've successfully subscribed to Justin Blanton.
Success! Your account is fully activated, you now have access to all content.