在Next主题配置文件中开启

主题配置文件路径:主题目录/_config.yml

menu:
  home: /||home
  about: /about/||user
  tags: /tags/||tags
  categories: /categories/||th
  archives: /archives/||archive
#  schedule: /schedule/||calendar
#  sitemap: /sitemap.xml||sitemap
#  commonweal: /404/||heartbeat

去掉"about"(关于)、“tags”(标签)、“categories”(分类)三项前面的#号。

执行Hexo命令

hexo new page "about"
hexo new page "tags"
hexo new page "categories"

命令执行后,会在source目录里建立对应的文件夹,并且会生成一个index.md文件。

配置index.md文件

在source目录中的对应文件夹中,修改index.md的内容。
以“tags”为例,它的index.md文件内容如下

---
title: about
date: 2020-06-24 17:34:17
---

需要data后面增加一行

type: "tags" 
注意,冒号后面有一个空格。分别填入"about"(关于)、“tags”(标签)、“categories”(分类)。

最终效果如下

---
title: about
date: 2020-06-24 17:34:17
type: "tags"
---

在文章中指定“标签”和“分类”

---
title: 为Hexo的Next主题开启“标签”、“分类”、“关于”菜单
date: 2020-06-24 17:25:10
categories: 博客搭建
tags: [Hexo]
---

编辑新文章模板

打开post.md

Hexo目录\scaffolds\post.md

编辑post.md的内容

title: {{ title }}
date: {{ date }}
categories:    #添加
tags:    #添加

如此,再次使用Hexo new 命令时出现的模板,会自动含有categories、和tags。

标签: Hexo, Blog

添加新评论