Hexo攻略-添加分类
1.创建“分类”选项
在命令窗口输入下方命令
hexo new page categories
/source/categories文件夹下会有index.md文件,打开后内容默认为:
---
title: categories
date: 2020-10-26 19:47:40
---
添加type: categories到内容中,添加后:
---
title: 分类
date: 2019-04-24 15:30:30
type: categories
---
保存并关闭文件。
2.新建文章并添加“categories”属性
在命令行输入下方命令创建新文章
hexo n “新文章名称”
在/source/_posts下自动生成.md文件,打开为其添加categories属性。下方的categories:Hexo攻略,表示这篇文章添加到到“Hexo攻略”这个分类。注意:一篇文章只会添加到一个分类中,如果是多个默认放到第一个分类中。
title: Hexo攻略-添加分类及标签
date: 2020-10-27 15:22:42
categories: Hexo攻略
至此,成功给文章添加分类,点击首页的“分类”即可看到该分类下的所有文章。效果如图。