Setting up a Blogging Environment

Recently, I have made a commitment to start blogging more seriously and regularly. First, however, I wanted to research the best blogging tools and settle on one that would meet my main needs for some time to come. Some criteria that were on the top of my list were:

  • Flexibility: Could I customize the UI and the background plumbing as needed? Granted, I didn’t want to build my own blogging tool from the ground up since there were already so many options, I still wanted to be able to tweak the theme I chose for the UI. I also wanted to extend the features using both the existing plugins and the new ones as they become available in the future.

  • Simplicity: Could I get up and running quickly? Would I hit any road blocks later? The simpler the system, the quicker I could get up to speed and the fewer issues I would need to deal with later on as well.

  • Community: Was I getting on board with a tool that will be around for a while? For this, I reviewed several sites including StaticGen.

While it was not a clear-cut and easy decision, in the end, I chose to go with Hexo. I will not go into further details on how I arrived at this conclusion because many of my considerations were very personal, such as choosing a tool based on Node.js versus one based on ruby because I already had a Node.js environment.

Once I settled on Hexo as the blogging framework, the next decision was where to host my blog. I had the option to push the content on to one of my servers or I could host it on GitHub Pages at a url such as ozbasarir.github.io for free with GitHub repository integration.

If I hosted on GitHub Pages, I could use the “hexo deploy” command (after installing the git deploy plugin with npm install hexo-deployer-git --save and updating _config.yml) to push updates of my posts to a GitHub repo. And since GitHub Pages would automatically publish the content of this repo, the changes would be live on the public blog site at the same time without any additional effort. Because I was already comfortable with GitHub and had created a few repos previously, this option appealed to me and I went with hosting on GitHub Pages.

Below is a diagram of my setup:

Blogging with Hexo from laptop/desktop

As you can see in this diagram, I am using Atom to edit the source files. These source files are created by Hexo as shown below:

.
├── source
├── _drafts
├── mypost1 (asset directory for mypost1)
├── myimage1.jpg
└── ...
├── mypost1.md
└── ... (an asset directory and a markdown file for each post)
├── _posts
└── ... (same structure as _drafts, for published posts)
└── about (each custom page is a separate directory like this one)

Atom has a live preview pane that comes handy when editing the Markdown (.md) files in the source directory.

Once a post is written, it is time to generate the public files that will be deployed to the server. These public files are the final static html pages and related assets of your blog.

To generate public from source, use the command:

hexo generate

To deploy public:

hexo deploy

Finally, I could navigate to my blog at the GitHub Pages url and proofread. GitHub Pages also gives the option to use your own domain name via a CNAME record.

Well, now that I have my blogging environment up and running, I will need to find new excuses to distract myself from writing the next blog post. Wish me luck :)