Using WSL and Node.js to build and manage Hexo

I had initially intended to publish this as part of my Azure DevOps entry, but it felt like it needed its own dedicated article. For my Hexo workflow I decided I wanted to use the Windows Subsystem for Linux from here on referred to as WSL. This works best for me because I am primarily a Windows user and I also have a fair bit of experience with Linux.

Getting Started

The first thing you’ll need to do is get Hexo configured locally so that you can generate the static content for later deployment, and also run your local server to test your content. The basics on how to configure Hexo are available on their website, I’ll cover how to do it on WSL specifically.

The first thing you need to do if you have not already is get WSL installed and running. Step by step instructions on this are available over on Microsoft Docs. The instructions below are specifically for the Ubuntu distro.

The below instructions assume a fresh install of the Ubuntu distro from the Windows store.

Getting npm and Node.js installed

You’ll need git for a variety of reasons, so let’s just get it installed first along with all of the prerequisites.

Install Git

sudo apt-get install git-core

Install NVM & Node.js

This is using Node Version Manager by creationix on GitHub. There are many ways to install Node.js, I went with the Hexo documentation.

wget -qO-

Run installation script:


Load NVM if it isn’t already loaded:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/" # This loads nvm

FInally, install node.js

nvm install stable

Install npm

In this step we’ll install the node package manager. npm is a package manager for node that will then allow you to install Hexo, plugins, and anything else you’d like to do with node.

sudo apt install npm

Install Hexo

At this point we are ready to install the Hexo cli which will allow you to finally build out a hexo environment.

npm install -g hexo-cli

Initialize a new blog

With WSL you can actually navigate to the Windows file system which means you can utilize tools like Visual Studio Code to edit your articles, templates and configuration files. For purposes of this article lets say we want to get Hexo running in c:\hexo

You can actually customize the mount point noted below. For example you could change it to /c/hexo instead of /mnt/c/hexo by modifying wsl.conf. You can also use these steps if you find that your Windows drives are not mounted inside WSL.

root = /
options = "metadata"

Full documentation on settings available in wsl.conf is available here.

Now initialize a new site in that location:

hexo init /mnt/c/hexo
cd /mnt/c/hexo
npm install

You will then have the following folder structure:

├── _config.yml
├── package.json
├── scaffolds
├── source
|   ├── _drafts
|   └── _posts
└── themes

That’s it! Now you are ready to configure your blog and start authoring content. Documentation for editing your site configuration can be found here.

Finishing Up

Now that you have the basics in place you can commit the directory to GitHub or Azure Devops and begin authoring posts and even installing custom themes if you want. Below are a few links to get you started:

  • Writing Content - This explains how to write new posts and pages as well as create drafts.
  • Miscellaneous Commands - This contains documentation on how to generate a static site, or launch a local server to test your newly created content.

I hope this article was helpful! You are now well on your way to publishing a Hexo blog in the wild. In my next article I will cover how to automatically deploy Hexo using an Azure Pipeline.

Why I chose Hexo for my Technical Blog

When the time came to relaunch my blog I spent a fair amount of time researching options. I wanted something that worked well for me that didn’t require too much infrastructure. I also wanted to keep costs fairly low and not take on a large monthly recurring cost.

  • Ideally, I wanted static content that I could host in an Azure Storage account or some sort of static website hosting.
  • I wanted something that felt comfortable for me. I spend a fair amount of time authoring articles in Markdown and it has really grown on me over the past few years.
  • An application with a fair amount of plugin and theme options, I don’t really want to get involved in creating a custom template. A reasonably sized community was a plus.

The Competitors

I evaluated a variety of different options before settling on Hexo. Obviously I’m sure there are more options out there, but this is what I looked at.

  • DocFX - I’ve had some experience with DocFX in the past and honestly, it is what I really wanted to use. But the lack of theme selection and the fact it’s primarily focused on documentation meant it was not a great fit for what I wanted to do. It is the engine behind Microsoft Docs and it does that really well so I will continue to monitor the project.
  • Hugo - A close second, Hugo is very similar to Hexo. It is built on Go rather than Node.js. It generates a static site that you can publish in much the same way. The configuration seemed a little bit more involved, but in the end it was almost a coin flip. Now that my content is in Markdown and ready to roll I may still give Hugo a try to compare and contrast.
  • Ghost - Their hosted platform pricing was a bit steep for me. And while they did offer self hosting the config seemed fairly complex and the requirements were also steep. I also don’t really need the fancy admin interface.
  • Medium - This is where my blog was before. It is a great platform for getting your content out there. But it’s not really a great platform for the true technical blogging that I wanted to do. I do still intend to post opinion pieces.. but not enough that Mediums core benefit would be that useful.
  • Wordpress - Obviously this option is one of the largest out there. And there are definitely a ton of options for plugins and themes. And I have experience with it in the past. But for me it felt like using a bulldozer to solve something I could use a shovel for.

Tech Blog Return!

I am happy to announce the return of the Hammer Time Tech Blog! I know you couldn’t wait for this to happen..

Recently I’ve been wanting to get back into blogging from a more technical perspective with some how to’s and lessons learned over my career. Previously the blog was hosted on Medium but that didn’t feel like the right… medium (harhar?) for what I’d like to be talking about these days.

There will still be some opinion posts and articles with things that I have on my mind. But in addition to that there will be more technical articles where I explain how I solved a problem or post some script snippets that helped me out. I also hope to further add to my GitHub which is sorely lacking in original content.

The first article coming soon will be how to use Azure DevOps to create a full CI/CD pipeline for publishing a Hexo site to Azure Storage using the new static website hosting feature. I’ll also explain my reasoning for moving to Hexo when there’s no shortage of blogging applications out there on the Internet.

I am really looking forward to sharing more knowledge in 2019!

Taking Evidence Seriously: Russian Hacking

One of the reasons I decided to start writing again was to put my experience in the field to good use. Primarily to explain the sometimes confusing world of Computers, Technology and Networking by making real world analogies. I hadn’t intended this to be political in any way but with what’s going on out there today it means that that’s what I’ve primarily been writing about.

So let’s talk about the recent hacking news based in the real world evidence and not hyperbole.

Unless you were living under a rock for the last half of 2016 you are aware that there was a massive leak of Democratic National Committee e-mails from key players in the Democratic Party. It’s been determined by a large number of public and private sector officials that these hacks were from the Russian Government. There are certain people who think that this can’t be true and while much of what occurred is classified, there is still plenty of public evidence readily available.

So how do they know that it was the Russians? Much like investigating a crime of say murder — the perpetrators leave behind key evidence like DNA, finger prints, fibers from their clothes, pieces of skin, etc etc. In a hacking attempt whether successful or not they also leave behind a signature. The tools used to infiltrate any systems whether government or private were created somewhere. I speak of things like malware and pieces of code that are created for the very specific purpose of gathering and extracting information from a target. The perpetrators will continue to use these toolsets in multiple attacks over time iterating on them and improving them, but the basis is still there — a signature if you will.

Why we need to take Online Communities Seriously

Recently I got into an argument in some Facebook comments (yea I know) regarding Online Communities. I’ve been thinking about it a lot recently with everything going on in this country.

It’s the Internet. You get a group of people together under a shroud of anonymity and guess what happens? Stupidity that shouldn’t be taken seriously.

I’ve been involved in a variety of online communities and I’ve even been at the helm of a few. I know that they can be fickle beasts with all sorts of crazy personalities, trolls, and debate. It can be very easy to shrug off comments or threats made by someone on the Internet “It’s the Internet. You get a group of people together under a shroud of anonymity and guess what happens? Stupidity that shouldn’t be taken seriously.” but having been the target of online harassment over the years I can tell you that it isn’t anything that should be shrugged off. I’ve even seen toxic people be celebrated and rewarded time and time again when they do nothing but blurt out vitriol and racism. I’ve seen those same people bring other people in to their cause and have those people do the harassment for them, its the modern day version of a henchman.

I say that it should be taken very seriously for a number of reasons.

Just this past weekend an armed man decided to waltz into a pizza shop to investigate a conspiracy theory that is a complete and utter lie.

Every single day teens are bullied online and many even commit suicide due to cyberbullying.

Understanding DirecTV Now and why it’s a problem for the Open Internet

If you aren’t an Engineer or don’t work in the tech industry the term “Net Neutrality” may not mean a whole lot to you. So I’ll start with a brief explanation of exactly what it is and why you should care about it.

Net neutrality for all intents and purposes is a means to ensure that the Internet is treated as a Utility. So what does that mean to you exactly?

Imagine if the electric company decided that they would reduce the voltage provided to your house. Instead of getting the promised 110v you were now getting 90v. Likely, this means that most of your appliances wouldn’t work and the things that did would would be unreliable at best. Net Neutrality makes sure that the same thing doesn’t happen with your Internet. Meaning that, say you were watching too much Netflix and the provider didn’t like that — They could simply “throttle” it and make it so your Netflix would be unreliable and constantly buffering. Funny enough, that actually happened.

The government has already made strides to insure that the Internet is treated as a utility, meaning that theoretically the above scenario isn’t possible anymore.

Or is it?

The announcement of DirecTV Now seems harmless enough but if you read between the lines you’ll find that they are actually exploiting a loophole in Net Neutrality. If you have an AT&T Wireless Data Plan you can use DirecTV Now and it won’t count against your data usage. Sounds great for you right?! In the Industry this is known as “Zero Rating” and is something that has been done a few times over the past several years (T-Mobile has done it). Unfortunately the FCC left the door open to this practice by electing to review these on a case-by-case basis.

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now