How I am using S3 and Jekyll to publish my blog

I decided to get of the schnide and become a more active blogger. Previously I had a legacy site utilizing a hosted environment with a typical Wordpress installation. I decided to utilize Amazon AWS S3 and Jekyll for my new framework due to the inherent availability and durability of S3 and the static build nature of Jekyll.

While this new venture is still in it’s infancy I thought I would share the steps I took to to reach the current publication. I want to cover a few items that may make you want to reconsider moving in this direction. The initial setup and configuration of this type of framework is for those more technically savvy, they refer to this type of setup as blogging like a hacker for a reason. You have to setup ruby, Jekyll, and some s3 goodies all from the command line so if you are not comfortable there then you probably want to look elsewhere. Also, I’m not going to dig into some of the deeper details around S3 and Jekyll, use goggle to fill in the blanks. If you don’t already have a favorite text editor find one, you will be spending most of your time in that interface creating your posts. Lastly, I use OSX as my OS of choice and the tips here have a OSX spin. I could speculate on creating an IDE in other OS’s but I’m sure google would lead you to more in depth examples.

Alright so the first thing to do is get Xcode installed on your mac. You can find the install in the App Store. Once you get Xcode downloaded and installed you are going to want to install the command line tools as well. This can be achieved from a terminal window using sudo xcode-select --install. Next you’ll want to run sudo port -v selfupgrade, this will get the command line tools up to date. I had to execute this command twice, the first time it appeared to error out but once I executed the command again it picked up and finished successfully. Next, we need to get Jekyll installed using sudo gem install jekyll. Jekyll is Ruby based so themes and plugins will usually require you to install the supporting gems. The final gem we need will allow us to push our jekyll generated static site to our chosen S3 bucket, sudo gem install s3_website.

At this point you are going to want to setup your Jekyll working directory, create your base site or find a theme, and generally get this site to a point that you would want to publish it online. I find using jekyll -w serve to test my site locally works best because it auto-regenerates page updates. This site uses a modified version of the So Simple theme. I created a port from github, downloaded a local copy, and began to make the changes I wanted to reflect my personal preferences. Additionally, the theme documentation provides instructions of initial setup and configuration.

Before you can publish your site you need to prep your S3 bucket. A couple items point out here. One if you are going to use a domain name of your own than you need to name your S3 bucket the same name as your eventual blog URL. For example this blog is named blog.onlystuff.com so that is the name I used for my S3 bucket. Remember S3 bucket names are all members of the same namespace so obviously you should not attempt name your bucket using a domain name you don’t control because you’ll never be able to update the DNS records accordingly. Next you are going to want to prep the bucket for web hosting. This can be achieved through the AWS console, however that method never worked for me. Time to issue the sudo s3_website cfg create command and update the resulting s3_website.yml file accordingly. This is how you provide the permissions to the gem for your bucket. Then I used the sudo s3_website cfg apply command to prep my bucket. If your 404 page is not named error.html than you’ll need to make that update on your S3 bucket properties, this appears to be hardcoded in the apply sub-command.

You are ready to publish. I have a couple of url entires in my Jekyll config to reflect my custom domain name url and my local url for testing. Make sure you have your public URL set before issuing sudo jekyll build. Once you have a static build simply issue sudo s3_website push, now you should see your files in the bucket. You should also be able to browse using the AWS provided DNS name for the bucket. The last piece would be to update your DNS records to point to the bucket.

I wrote this piece after working thru the process so I may have missed a step or two, post a comment and I’ll make an update as necessary.