Solve the problem that the classification and label cannot be displayed under hexo

Overview
Today I changed a new theme, and later found that I couldn't add category pages and tab pages normally. After an afternoon of research, I finally found the most perfect solution.

Step 1
You need to create a tags folder under the source folder of the hexo root directory, and then create an index.md file in the tags folder. The shortcut commands are:

$ hexo new page "tags"

Step 2
Edit the index.md file, the content is as follows:

---
title: "tags"
type: tags
layout: "tags"
---

Here comes the point

note! The most important thing here is the layout option. The following parameters correspond to the first-level layout file in the layout folder under your theme folder. For example, if my theme is written in ejs, the corresponding is layout/tags.ejs, if not, then there will be a blank phenomenon! If your tags file is named a.ejs, then you should write layout: "a".

Step 3:
Edit the theme configuration file:

nav:
  home: /
  about: /about
  tags: /tags

Step 4
Edit the Directory option of the hexo configuration file.

Check if the name corresponds

# Directory
tag_dir: tags

So far, a perfect solution.

The most important thing is to see if there is a layout file for the label page or category page in your theme file. Generally speaking, there are some, but the naming and storage location may be different, so you have to modify it according to the actual situation.

Guess you like

Origin blog.csdn.net/weixin_42118981/article/details/109462491