Hexo - Node.js Blog Framework


hexo - A fast, simple & powerful blog framework, powered by Node.js.

Official Website hexo.io

Prepare the environment

Install Node

Visit Node.js official website to download the latest version for the platform, all the way to installation. I use node-v0.10.26.pkg.

Git Configuration & GitHub Account Register

Git software configuration based on SSH key production

First configure their own account created on Github Git software in the user name and E-mail address. If not you can go to GitHub registered first.

Establish correspondence with your username warehouse, warehouse name must be your_user_name.github.com

Adding SSH public key to the "Account settings → SSH Keys → Add SSH Key"

$ git config --global user.name "Your Name Here"
# Sets the default name for git to use when you commit
$ git config --global user.email "[email protected]"
# Sets the default email for git to use when you commit

Then if already have a SSH key checking system

$ cd ~/.ssh
# Checks to see if there is a directory named ".ssh" in your user directory

If "No such file or directory", then there is no need to re-establish. If so, you can back up your key and then remove the old.

$ ls
# Lists all the subdirectories in the current directory
# config  id_rsa  id_rsa.pub  known_hostsmkdir key_backup
# Makes a subdirectory called "key_backup" in the current directory
$ cp id_rsa* key_backup
# Copies the id_rsa keypair into key_backup
$ rm id_rsa*
# Deletes the id_rsa keypair

Then generate a new SSH key. When prompted to Enter a file in which to save the key when you can just press Enter to keep the default settings, namely the presence of their own home directory (you Ubuntu replaced their account name, the same below). E-mail address with front and Github account is the same:

$ ssh-keygen -t rsa -C "[email protected]"
# Creates a new ssh key using the provided email
# Generating public/private rsa key pair.
# Enter file in which to save the key (/home/you/.ssh/id_rsa):

Press Enter will be prompted to enter a password and confirm password:

Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]

Then see a message similar to that showed the success of key generation

Your identification has been saved in /home/you/.ssh/id_rsa.
# Your public key has been saved in /home/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected]

In Github SSH key and enter the server detects the connection success of.

Log in to your Github account, enter "Account settings / SSH Keys", you can enter just generated key.

Then you can try to detect what Github SSH server to connect to the git.

$ ssh -T [email protected]
# Attempts to ssh to github

Might see such a warning, but no relationship, enter yes and press Enter

The authenticity of host 'github.com (' can't be established.
# RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
# Are you sure you want to continue connecting (yes/no)?

Finally, you can see such a successful connection message

Hi username! You've successfully authenticated, but GitHub does not
# provide shell access.


After Node and Git are installed, run the following command to install hexo

$ sudo npm install -g hexo


Then, run the init command to initialize hexo to the directory you specify

hexo init

You can also cd to the target directory, execute hexo init.

Well, so far, all of the installation work has been completed!

Generate Static Page

cd into your init directory, execute the following command to generate static pages to hexo\ public\ directory.

hexo generate

Init command must be executed in the directory, otherwise unsuccessful, but it is not an error.

When you modify the contents of the article Tag or not properly re-generated content, you can delete hexo\ retry after db.json, not enough on the public directory delete the corresponding files regenerat.

Local Launch

Run the following command to start local services, carried the article preview debugging

$ hexo server

Browser visit http://localhost:4000 can see the effect.

Writing articles

Execute new commands, specify the name of the article to generate hexo \source\_posts\postName.md.

hexo new [layout] "postName" # New post

Which layout is an optional parameter, the default value post. What layout do, go to the next scaffolds catalog view, the file name is the layout of these names. Of course, you can add your own layout, is to add a file to, and you can also edit an existing layout, such as the layout post default hexo\scaffolds\post.md.

title: { { title } }
date: { { date } }

Please note that between the braces and braces I pay more a space, otherwise it will be an escape, not display properly.

I want to add categories, so as not to be entered manually each time, you only need to modify this file to add a line, as

title: { { title } }
date: { { date } }

postName is the name of the .md file, and also appears in the URL of your article, postName if it contains spaces, you must use "its surrounds, postName can be Chinese.

Note that all files: behind must have a space, or error.

Just look at the generated files hexo\source\_posts\postName.md, which reads as follows

title: postName # Display name on the article page, can be modified, does not appear in the URL
date: 2014-04-07 10:03:16 # Articles generation time, generally do not change, of course, can be modified
categories: # Article categories, can be empty, note: there is a space behind
tags: # Article Tags can be empty, please use the multi-label format [tag1, tag2, tag3], note: there is a space behind
Using markdown format of the input text.

Next, you can enjoy with your favorite editor to write your article. About markdown syntax, you can refer to Markdown Example.

0.00 avg. rating (0% score) - 0 votes