A clickbait title, yes, but the post beneath delivers! It’s not automatic, it’s not fire and forget, but it’s as reliable as it is dirt-cheap. And you might not always pay 18¢/month… one month, I paid 8¢, and nothing at all most months. Even better, if 18¢/month is a problem, you can get hosting for free for the first year. Of course, domain registration is still $20 or more every year, so it’s not like you can set up your writing site completely with pocket change. Still…

Miracles Happen

When most hosting sites want 18 dollars per month (more or less) to host your site, how am I getting mine for 1% of that (or less, some months)? There are three components to this miracle:

  • Jekyll (a Free static site generator, packaged as a Ruby gem)
  • Amazon Web Services (AWS)… of course it’s Amazon, right?
  • s3_website (a Ruby gem that manages a static website on AWS)

If you’re a web developer, you’ve certainly heard of Ruby. More than a scripting language, it’s a complete web development environment. Like most software environments, it supports a package system (and programmers, being fond of puns, call the packages gems). Fortunately, if you’re not a web developer, you can do everything using gems. Create your content, and let the gems do the rest.

Getting Started

If you’re fortunate enough to be using MacOS X, you already have a version of Ruby that supports everything you need. Just open a Terminal (yes, you’ll have to get acquainted with the command line) and type:

gem install jekyll s3_website bundler

On that Microsoft thing, you’ll need to install Ruby first. Fortunately, the Jekyll website has instructions. I did this on a work computer, for a work-related project, and it worked. Once you have Ruby set up, use the same gem install command listed above to get the essentials.

Linux can be… um, interesting. For example, Ubuntu and its derivatives have Ruby, but the supported version is too old to support Jekyll. You might want to Google ruby jekyll your distro for wisdom. I got Jekyll running on my Linux laptop (an ancient MacBook running Xubuntu), so I know it’s possible. Once you have an updated version of Ruby installed, use the same gem install command listed above to get the essentials.

Variations on a Theme

For your first poke at Jekyll, it’s easiest to work with the defaults. So, assuming you have a Documents folder, you can use these commands to set up a basic Jekyll website:

$ cd ~/Documents
$ jekyll new sitename

This creates a directory called sitename (or whatever you called yours), and populates it with a few essential files and directories. You’ll want to edit _config.yml to personalize the site; the most important lines to start with are:

  • title (the site title)
  • author (your name)
  • description (a sentence or two that describes your site and its purpose)
  • email (your email)

There’s some sample content, too. To see it, type:

bundle exec jekyll serve

This starts a basic web server, so you can preview your site. To see it, open http://localhost:4000/ in your browser.

Jekyll’s default theme is called Minima. There are hundreds of other themes to choose from, so you can get the look you want without a lot of effort. Check out http://jekyllthemes.org/ to find something you like. Most of them come as zip files, so you can unpack them into your directory and get to work.

Content is King

Jekyll creates HTML files from either Markdown or partial HTML files. Any file that begins with a YAML block (metadata) gets converted. Blog posts lives in the _posts folder, and have some specific metadata. Here’s an example:

---
title: 'Three Steps to Crash-Proof Your Writing'
layout: post
date: 2017-06-13 07:00:00
author: Larry Kollar
categories: technology
tags: prevention
---

Depending on your theme, you might omit a few of these and add others. Check the documentation for the theme for details. One important one is permalink: It specifies the name and even the location for the output page (you usually won’t use it for blog posts).

Building Your Website

Now that you’ve put your website together, and maybe added a few blog posts, it’s time to see what it looks like. Use the following command to build the site:

bundle exec jekyll build

The output goes into the _site folder. You can have a look at the generated HTML, open it in a browser, and so on. Editing it is also possible, but any changes you make get clobbered next time you build.

If you want to see how the site looks online, type:

bundle exec jekyll serve

This builds the site and starts a basic webserver. Use http://localhost:4000/ to access it. You can make changes to your source, and Jekyll automatically rebuilds the site. Wait a few seconds, then refresh.

Setting up on AWS

Okay… you now have a site, and at least the beginning of some content. It’s time to deploy it.

Amazon Web Services (AWS) is a sprawling beast. If you need an online presence—no matter how you prefer it—they probably have you covered. You can set up anything from a file repository, to a static website, to Wordpress or other database-driven sites, to full-blown virtual servers, and there’s other stuff that I’m not even sure what it is.

The part of AWS we’ll deal with is called S3 (Simple Storage Service). It can be used many different ways, including custom cloud storage, but we’re focusing on static web sites. The s3_website gem makes setting up and publishing easy.

  1. Set up AWS credentials. You should now have an ID and a secret.
  2. Set up your configuration:
    • Go to your website directory.
    • Type s3_website cfg create to create the s3_website.yml configuration file.
  3. Edit the s3_website.yml file and change the following fields:
    • s3_id: the ID you received in step 1.
    • s3_secret: the secret you received in step 1.
    • s3_bucket: the bucket name you want to use (usually the website address, like www.example.com).
    • ignore_on_server: logs/*
  4. Type s3_website cfg apply to create your S3 bucket and set it up as a static website.

When you’re ready to publish your site, type s3_website push. The first time, it uploads your entire site (as expected). After the first time, it uploads only new and changed files. On occasion (and always the first time), it downloads a Java app that does some of the work.

Now all you have to do is point your domain to your S3 bucket, and tell everyone where to find your new website.

Sound off

Did you try this? How did it work? Let me know in the comments.