Open source blog making framework - Hexo

Step by step guide to create a blog using Hexo!

Check documentation for more info.

Find most of your answers in troubleshooting or ask on GitHub.

Quick Start

Prerequisites

Visual studio code
Github account
Install git
Install node.js

Create a folder say c:\Hexo on your machine, and open the folder in VSCode, then follow below steps

Install Hexo

Open command prompt ctrl+` and execute

1
npm install -g hexo-cli

Once installed Hexo, check the hexo installation using below command

1
hexo --version

Create a blog

1
2
3
hexo init myblog
cd myblog
npm install

Create a new post

1
hexo new "My New Post"

More info: Writing

See the blog

1
hexo server

More info: Server
Open browser and type http://localhost:4000 to see your blog

Preview Drafts

1
hexo server --draft --open

Any static files under the _drafts folder will be available to preview on localhost site only

Generate static files

1
$ hexo generate

More info: Generating

Deployment using github account

Create a github repository
For my account sunilpatro1985, I will create a repository as sunilpatro1985.github.io
Note: Select public and add.gitignore as Node

Site url will be now https://sunilpatro1985.github.io

but we are not done yet, we have to deploy our blog to git

1
npm install hexo-deployer-git --save

Get the repository weburl from github (on the github repository, click on clone or download button and copy the web url)

Now on the _config.yaml file, update the deploy section

1
2
3
4
5
deploy:
type: git
repo: https://github.com/sunilpatro1985/sunilpatro1985.github.io.git
branch: master
message: "{{ now('YYYY-MM-DD HH:mm:ss')}}"

Once done, now deploy to see the blog live

1
$ hexo deploy

More info: Deployment

Navigate to sunilpatro1985.github.io on browser to see the blog live!!!

Note

Some times deploy gives message nothing to commit, then try with hexo clean and then
hexo deploy

Source

Share