The thoughts, rants, tips, tricks, stories, truths, and lies of Jordan Irwin

July 9, 2014

Setting up this blog, Part 2

Full Series: Part 1, Part 2, Part 3, Part 4

A great deal of time was spent getting my environment configured reasonably sane. By environment, I mean:

  • Directory structure.
  • Git.
  • Writing.
  • Previewing.

Directory Structure

My directory structure can be viewed on GitHub (this blog and its source is wide-open for your review). I went through a few iterations, and may still go through more, but it’s a fairly standard structure for GitHub Pages + Jekyll.

Git

GitHub Pages has great documentation available, but it wasn’t a silver bullet. GitHub Pages requires at least two branches: One to host the blog itself and one to store the source code for generating the blog. GitHub Pages respects a magical branch called gh-pages or the master branch. I chose to go with master for hosting and source for the source code. Admittedly, I didn’t get this right at first (or second, third, or tenth).

Since I already had some source code in the master branch, I needed to change things around. I created a new branch for the source code:

git branch source --orphan

Then, I needed to cleanup my master branch of everything but the .git folder (well, anything that doesn’t start with a period (.):

find . -regex "\./[^.].*" -exec rm -rf {} \;
git commit -m "insert kewl comment here"

Now I have a clean master and a fully loaded source. I’ll never do anything directly in the master branch. Everything will be done in source, then deployed (NOT merged!) to master. These two branches will never merge together again.

Writing

Deciding what to write with was easy, Sublime. Cross-platform, settings configured via JSON files, great plugin support, and sports a minimal UI- I love it. I currently use pretty basic settings and only two plugins: Package Control for installing packages (plugins) and Markdown Preview for lovely Markdown syntax highlights.

Previewing

As mentioned above, Markdown Preview offers some nice Markdown enhancements- including previewing via your browser. While I do use this feature when writing notes or other Markdown based documents, this blog is previewed via Jekyll for an identical match to the final product.

To setup a local copy of the blog at http://localhost:4000 and automatically update modified files for real-time previewing, I use this command line from my source branch:

jekyll serve -w

I use Safari to browse the URL and refresh as I want to preview changes.

Next Part: Jekyll and building the blog’s HTML.