0%

Hexo Usage

Hexo Usage

How to Write a new post

  1. Generate new post in your terminal: hexo new "Your post name"
  2. Open your project by vscode, then open file: source\_post\Your post name.md
  3. Edit your post with vscode, hexo support markdown and ejs files

Clean cache

  1. After finish editing, you can type hexo clean in your terminal to clean the cache, clean is short for clean here.
1
hexo clean

Generate static files

  1. After finish editing, you can type hexo g in your terminal to generate static files, g is short for generate here.
1
hexo g

Publish your post

  1. Type hexo d to deploy your post to github.io, d is short for deploy here.
1
hexo d

View your post

  1. open zdd.github.io to see your post, good job!

you can use npm run deploy to combine generate and deploy in a single command.

View post locally

  1. Run hexo s in terminal, then open localhost:4000 to see your post, this is very convenient to check your post before publish.
1
hexo s

404 File not found

When you encounter the 404 error, make sure to do the following

  1. Check your source\_post\Your post name.md file name, make sure it is the same as the title in the file.
  2. run hexo clean to clean the cache
  3. run hexo g to generate static files
  4. run hexo d to deploy your post to github.io

Tags not working

  1. Make sure you have a tags folder under source folder
  2. Install easy tag plugin by npm install hexo-easy-tags-plugin --save
  3. Delete .deploy_git folder
  4. Run hexo clean to clean the cache
  5. Run hexo g to generate static files
  6. Run hexo d to deploy your post to github.io
  7. Force refresh your browser by Ctrl + F5

Make sure tags config in themes\next\_config.yml is correct, remember to set amount to a large number

1
2
3
4
5
6
7
tagcloud:
# All values below are same as default, change them by yourself.
min: 12 # Minimun font size in px
max: 30 # Maxium font size in px
start: "#ccc" # Start color (hex, rgba, hsla or color keywords)
end: "#111" # End color (hex, rgba, hsla or color keywords)
amount: 2000 # <--------------- Set this to a large number

How to add tags

  1. Run hexo new post "tags"
  2. Make sure tags/index.md has the following content
    1
    2
    3
    4
    5
    ---
    title: tags
    date: 2023-06-30 23:21:34
    type: "tags"
    ---

Add multiple tags for a post

  1. Add tags in the front matter of your post, for example:
    1
    2
    3
    4
    5
    6
    7
    ---
    title: Hexo Usage
    date: 2023-04-16 22:03:56
    tags:
    - hexo
    - blog
    ---

Insert Read more tag to post

1. Insert `<!-- more -->` in your post, for example:
   
1
2
3
4
5
6
7
8
9
10
11
12
---
title: Hexo Usage
date: 2023-04-16 22:03:56
tags:
- hexo
- blog
---

# Hexo Usage
## How to Write a new post
<!-- more -->
# other content