0%

hexo 新增 tag、catagories、about等頁面

版本

hexo: 4.1.1
hexo-cli: 3.1.0

node: 10.15.0

終端機輸入 hexo version 可看到版本訊息

1. 修改 index.md

一般來說,用 hexo init 一個專案,就會自動在 source 資料夾下幫你生成 about/tags/categories 等資料夾,裡面有 index.md,如果找不到頁面,可用以下語法新增

1
2
3
hexo new page tags
hexo new page categories
hexo new page about

新生成的內容只有

1
2
3
4
---
title: about
date: 2019-12-23 22:23:34
---

需手動加上加上 type

1
2
3
4
5
---
title: about
date: 2019-12-23 22:23:34
type: "about"
---

categories、tags 比照辦理,type 跟 title 一樣即可

2. 修改主題設置文件 _config.yml

把要出現在畫面的 menu 註解拿掉

注意 hexo init 好的專案預設值是 / || home,因格式問題,需將斜線後的空格拿掉 /|| home,否則會發生慘劇

最終長這樣

之後發表文章時有加上 categories,如:

1
2
categories:
- Hexo

categories 頁面就會自動顯示用到的分類了

踩雷專區

1. 為什麼 hexo 換 next 主題,修改完 menu 配置後,點進去卻是 cannot GET tags/20%/ ?

%20 是空格的意思,在主題配置文件 _config.yml 中,將 home: / || home 改為 home: /|| home

更新: 後來發現是裝錯 NexT 版本,不要https://theme-next.iissnan.com/ 這裡下載,完全被雷到= =