Last Updated: July 21, 2017
· cleechtech

Get blogging with node.js and Hexo

Install and Create

$ npm install hexo-cli -g
$ hexo init hexo-blog
$ cd hexo-blog
$ npm i

You'll see a wordpress-esque blog. Browse to find a new theme that you like here: https://github.com/hexojs/hexo/wiki/Themes

Change Theme

I chose Casper theme. We get the theme from its github repo and place it into the themes folder of our project:

$ git clone https://github.com/kywk/hexo-theme-casper.git themes/casper

in _config.yaml update the themes section:

# Extensions
## Plugins: http://hexo.io/plugins/
## Themes: http://hexo.io/themes/
theme: casper

Restart the hexo server and voila your blog has an entirely new look.

Also add some basic info at the top of _config.yaml:

# Site
title: Connor's blog
subtitle: Built on Hexo
description: Javascript tutorials and other stuff
author: Connor Leech
language: en
timezone: America/Los_Angeles

Here is a list of timezones.

Write a Post

$ hexo new post "My First Post"

Then the post will be autogenerated in source/_posts/My-First-Post.md. Fill it out:

title: My First Post
date: 2015-09-23 12:43:41

blah blah blah

### I can

## Write

In markdown

**ohhhh right***

So restart the server and the post will show up. There will be a strange author summary. To change that, and configure other parts of the Casper theme go into themes/casper/_config.yml.

# config
cover: //blog.ghost.org/content/images/2013/Nov/cover.png
logo: //blog.ghost.org/content/images/2013/Nov/bloglogo_1-1.png
bio: 'Connor made this custom bio about himself'

# Content
excerpt_link: Read More

# Miscellaneous

Deploy to Github Pages

$ npm install hexo-deployer-git --save

Create a github repo and config for deploy in _config.yml:

# Deployment
## Docs: http://hexo.io/docs/deployment.html
  type: git
  repo: git@github.com:cleechtech/hexo-blog.git
  branch: gh-pages

So that will ship the deployment build up to a github repo you specify. When you view try to view it though at <your_base_github_page>/hexo-blog where hexo-blog is the name of your deployment repo, you will not see any styling! This has to do with base url issues and github pages. I am still looking for a fix.

To deploy and redeploy:

$ rm -rf .deploy_git
$ hexo deploy

Follow me on Twitter

Originally posted on Medium, Source code on Github