Create a Free Tech Blog

The Internet is wondrous technology. If anyone remembers Geocities and Personal Home Pages, you can appreciate just how much the Internet has evolved. This evolution has recently enabled creating a tech blog completely for free. When I say free, do I mean completely free? Yes, completely free! Even this very blog, my Year of Commits, is hosted for free using the same technologies outlined in this post. You too can have a free tech blog after following these 2 simple steps.

Step 1. Use Jekyll

Jekyll is a free open source static site generator. The Jekyll documentation page has some great tutorials that make getting started extremely painless. Jekyll is also a ruby tool. To contribute to Jekyll, check out their github page.

Jekyll makes it easy to start creating content without worrying about CSS, page templates, or link architecture. It even generates an RSS feed of your content. All pages can be written in Markdown and automatically converted to HTML upon building or serving the site. The jekyll build command is what this post will focus on, but jekyll serve is worth checking out too.

To get started with Jekyll:

$: gem install jekyll
$: jekyll new mytechblog
$: cd mytechblog/
$: touch _posts/2015-07-12-my-first-post.markdown

This will create a new directory with some default configuration files and subdirectories. Inside this new directory, the example created a 2015-07-12-my-first-post.markdown file within the _posts/ subdirectory. This file will contain the content for the first blog post.

Jekyll Markdown pages require a specific format at the top of the file. This format is called front matter. It is imperative that all Jekyll posts have proper front matter in order to be converted to HTML.

Step 2. Use Github Pages

Github has been a great tool for managing version controlled software for years. Now, Github has released an equally awesome tool called Github Pages. To get started with Github Pages, simply create a public repository with the pattern: <yourusername>.github.io (Remember to replace the <yourusename> with your actual username). Now, every time a commit is pushed to this repository’s master branch, the blog will be automatically updated. Since this repository is required to be public, make sure that no sensitive information is accidentally committed within posts.

To set up a directory and point it to the github.io repository:

$: mkdir username.github.io
$: cd username.github.io/
$: git init .
$: git remote add origin git@github.com:username/username.github.io.git

The files uploaded to the Github Pages repository should be static HTML. This is where Step 1 comes in. Since this blog will use jekyll build, the <yourusername>.github.io repository should consist of HTML files generated by Jekyll.

To generate the HTML files:

$: cd mytechblog
$: jekyll build --destination=~/username.github.io
$: cd ~/username.github.io
$: git add .
$: git commit -m "First blog post"
$: git push origin HEAD

And there you have it! A successful blog created entirely for free. Now, the example blog is accessible at http://username.github.io.

(Optional) Step 3. Use a custom URL

To serve a blog at a custom URL, simply add a single file to the root of the <yourusername>.github.io repository. The filename must be CNAME and it should include a single line: the custom URL.

An example CNAME file:

mytechblog.com

Additionally, the DNS provider that mytechblog.com’s DNS is served from must include an ALIAS, ANAME, or A record to the Github IP. More information on setting a custom domain can be found at the Github help page

Final Step: Blog for free about cool technology

Now that a completely free blog is newly created, you have the ability to update it as frequently as you choose. Share your knowledge at expeditious paces by simply making commits to a public repository. Never worry about hosting costs, server configuration or deployment again. Simply write Markdown, build static HTML, and commit!