Hexo Installation and Usage

📢 This article was translated by gemini-3-flash-preview

My server was about to expire recently, so I decided to migrate VRC Blog to GitHub. I started looking for a good theme. I originally wanted to use the Typecho theme I’m currently using (which was ported from Jekyll), but I couldn’t find it when I searched for it half a year ago. Lately, I’ve been wanting to check out Hexo. After searching for themes, I remembered that Argon, which I really like, has a Hexo version. Hence, this article.

Environment

Requires Node.js 10.13 or higher (12.0+ recommended).

Requires Git.

Installation

Run the command:

1
npm install -g hexo-cli

Check if the installation was successful:

1
hexo -h

Create a New Blog

Navigate to the folder where you want to install:

1
hexo init <folder_name>

Enter the folder:

1
cd <folder_name>

Install dependencies:

1
npm i

After creation, you can modify ./_config.yml for configuration.

Install a Theme

Pick a theme from the Theme Store . Installation methods may vary by theme, so refer to the specific theme documentation.

The following steps are for the Argon theme:

Clone the Theme

First, clone the theme repository into the ./themes folder:

1
git clone https://github.com/solstice23/hexo-theme-argon.git

Rename the cloned folder to argon.

Install the ejs renderer:

1
npm install hexo-renderer-ejs

In the ./_config.yml file, set the theme to argon.

Configuration File

Modify ./themes/argon/_config.yml to change settings.

Run this in the root directory:

1
npm install hexo-generator-search --save

Then add the following options to ./_config.yml:

1
2
3
4
search:
  path: search.xml
  field: post
  content: true

Writing

Create a new post:

1
hexo new [layout] <title>

[layout] is an optional attribute:

LayoutDescriptionPath
postPost (default)source/_posts
pagePagesource
draftDraftsource/_drafts

Once created, you can start writing your article.

Preview:

1
hexo s

Visit localhost:4000 to view.

Generating Static Files

Run the command:

1
hexo generate

Running this command only generates files that don’t exist yet. It’s usually better to clean the previous build before generating.

References

https://hexo.io/docs/

https://github.com/solstice23/hexo-theme-argon

This post is licensed under CC BY-NC-SA 4.0 by the author.