1. Environment Setup
Install the following tools in advance:
- Node.js (v16+ recommended): refer to the Runoob tutorial for installation](https://www.runoob.com/nodejs/nodejs-install-setup.html)
- Git: refer to the Runoob tutorial to complete installation and configuration, and register a GitHub account](https://www.runoob.com/git/git-install-setup.html)
Verify the installation:
1 | node -v |
2. Installing Hexo
Refer to the official Hexo installation documentation](https://hexo.io/zh-cn/docs/)
1 | npm install -g hexo-cli |
On Linux you can run the following command. You can use hexo [command] directly; otherwise you need to use npm hexo [command]
1 | echo 'PATH="$PATH:./node_modules/.bin"' >> ~/.profile |
Create the blog project:
1 | hexo init my-blog |
At this point the directory structure is as follows:
1 | my-blog/ |
Start the local preview:
1 | npx hexo server |
Open http://localhost:4000 in your browser to see the default page.
3. Installing the Fluid Theme
More themes can be found in themes](hexo.io/themes/).
Method 1: npm installation (recommended)
1 | npm install hexo-theme-fluid |
Method 2: Direct download (this blog uses this method)
Download the latest version from Fluid GitHub Releases](https://github.com/fluid-dev/hexo-theme-fluid/releases) and extract it to the themes/fluid directory.
Enabling the Theme
Edit _config.yml in the root directory and modify the theme field:
1 | theme: fluid |
Create a theme configuration file (to override the theme's default configuration; no need to modify files inside themes/fluid):
1 | cp themes/fluid/_config.yml _config.fluid.yml |
If installed via npm, copy it from
node_modules/hexo-theme-fluid/_config.yml.
Restart npx hexo server, and you should see the Fluid theme's pages.
4. Basic Configuration
4.1 Site Configuration (_config.yml)
1 | title: My Blog # 站点标题 |
4.2 Theme Configuration (_config.fluid.yml)
Commonly used configuration options:
1 | # 导航栏标题 |
For more configuration options, refer to: Fluid Configuration Guide
5. Writing Articles
Creating a New Article
1 | npx hexo new "My First Post" |
This will generate My-First-Post.md under source/_posts/. Edit its content:
1 | --- |
Common Front-matter Fields
| Field | Description |
|---|---|
title |
Article title |
date |
Publication date |
tags |
Tag list |
index_img |
Homepage cover image |
banner_img |
Large banner image at the top of the article page |
sticky |
Pinning priority; larger numbers appear closer to the front |
hide |
Set to true to hide site-wide |
archive |
Set to false to hide only on the homepage |
Creating a Draft
1 | npx hexo new draft "Draft Title" |
Drafts are stored in source/_drafts/ and will not be published. When you want to publish:
1 | npx hexo publish "Draft Title" |
6. Create tabs, about page, etc.
1 | npx hexo new page tags |
Edit the generated source/tags/index.md:
1 | --- |
Edit source/about/index.md:
1 | --- |
7. Deploy to GitHub Pages
Refer to the official Hexo GitHub configuration docs
7.1 Create a GitHub Repository
Create a repository on GitHub named yourusername.github.io (replace with your GitHub username).
7.2 Initialize Git and Push
1 | cd my-blog |
7.3 Configure GitHub Actions for Automatic Deployment
Create .github/workflows/pages.yml in the project root directory and copy the following content into it. Note that the Node version needs to be modified (in the sample code below it is 24.14.0). Use node -v to check it, and note that the output is in a format similar to v24.14.0 — do not include the "v", or the workflow will fail to run.
1 | name: Pages |
7.4 Enable GitHub Pages
- Go to the repository's Settings → Pages
- Set Source to GitHub Actions
- After pushing the code, Actions will automatically build and deploy
Once deployment is complete, visit https://yourusername.github.io to see the blog.
8. Daily Workflow
1 | # 写新文章 |
Common Commands Quick Reference
| Command | Description |
|---|---|
npx hexo new "Title" |
Create a new post |
npx hexo new page name |
Create a new page |
npx hexo server |
Local preview (port 4000) |
npx hexo generate |
Generate static files to public/ |
npx hexo clean |
Clear cache and generated files |