Hexo

Introduction

Hexo is a static website builder based on nodejs and markdown which supports remote deployment and theme customization.

Hexo Installation

Node.js

The installation program,including node and npm.

1
2
$ node -v  # check the version of node
$ npm -v # check the version of npm

The step of installation:

1
2
$ npm install -g cnpm --registry=http://registry.npm.taobao.org  # install the cnpm manager of taobao
$ cnmp install -g hexo-cli # install the scheme of hexo

Git

In windows, all the command line commands should be run in Git bash. Github can serve as the remoete blog of our local hexo blog:

  • Create a new repositry in github,whose name is YourGithubName.github.io;

  • Install the git deployment plugin;

    1
    $ cnpm install --save hexo-deployer-git
  • Configure _config.yml.

    1
    2
    3
    deploy:
    type: git
    repo: https://github.com/YourGithubName/YourGithubName.github.io.git
  • Visit remote blog through https://YourGithubName.github.io/.

Hexo theme

Download the specific theme from github:

1
$ git clone https://github.com/themename.git themes/themename

Configure _config.yml:

1
theme: themename

Then, configure the theme with the help of its manual.

Hexo Command

Create a folder in computer and use this folder as the root of our blog.

1
$ hexo init [folder]

Create a new blog:

1
$ hexo new <title>

Create categories or tags:

1
2
$ hexo new page categories
$ hexo new page tags

Once we edit our blog,we should:

  • Clean cache files.

    1
    $ hexo clean
  • Generate new public blog. That is the content we use to build our website.

    1
    $ hexo g

Start our server:

1
$ hexo s

Deploy our blog to remote site:

1
$ hexo d

All the file created in command line will be placed in /source.

Local article link

Jump to the specific local article:

1
2
3
{% post_link 'YourPostName' LinkName %}  // the default linkname is the name of article
or
<a href="{% post_path 'YourPostName' %}">LinkName</a>

Jump to the specific catalog of local article:

1
2
// Use '#' for all levels of catalog
<a href="{% post_path 'YourPostName' %}#CatalogName">LinkName</a>

You can also use:

1
[LinkName]({% post_path 'YourPostName' %}#CatalogName)

But when you configure the path of your local image like this: Image, this method will fail.

If your CatalogName has space, you should replace the space to -. The same to YourPostName if you do not use ''.

Custom article priority

See Hexo设置文章的优先级别.

Some bugs

Only show Chinese '

This is a setting bug of marked renderer, turning off smartypants can solve it:

1
2
marked:
smartypants: false

Reference

HexoDocs