Hexo next 主题配置右侧栏的分类和标签打开的是空白

基本搭建好后发现,分类或标签点进去网页不存在,但是具体的一个分类能够进去。

原来是没有设置好,解决起来也很简单。

一、 新建 标签 和分类 页面

在根目录输入命令 hexo new page categories 会自动新建 categorier 文件夹并生成一个index.md文件,将里面的代码改为:

---
title: categories
date: 2020-01-21 12:12:26
type: "categories" 
---

同理,「标签」也一样 hexo new page tags 生成 tags 文件夹,其中会自动生成一个index.md文件,将代码改为:

---
title: tags
date: 2020-01-21 12:13:08
type: "tags"
---

二、配置菜单

在主题文件下的_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

# Enable / Disable menu icons / item badges.
menu_settings:
  icons: true

三、使用时

如果要对文章使用「tags」「categories」,只需在文章开头添加如下代码:

---
title: 摸鱼
date: 2020-01-21 12:04:59
tags: 杂项
categories: 技术
---

为了方便,我们可以修改post模板,修改Hexo\scaffolds\post.md

---
title: {{ title }}
date: {{ date }}
tags:
categories:
---

参考链接:

1. https://www.jianshu.com/p/f138032e7539

2. https://blog.csdn.net/mqdxiaoxiao/article/details/93644533

猜你喜欢

转载自www.cnblogs.com/lfri/p/12221359.html