这篇文章上次修改于 1682 天前,可能其部分内容已经发生变化,如有疑问可询问作者。
hexo默认的文章全部存在\source\_posts\
一个文件夹下面,文章一多就不方便管理。
所以对_posts
目录里的文章按日期进行适当的整理。尝试了一下,找到了比较满意的做法。
文章的默认地址为:域名/年/月/日/标题(文件名)
例:我现在hexo new post 001
会在\source\_posts\
生成一个001.md
文件,该文章的链接为:https://waitung.cc/2018/06/18/001/
假设:
2017年11月16日写下开始用hexo写文章
2018年02月25日写下去XX旅游
2018年05月03日写下常用工具整理
默认设置下:hexo new post 开始用hexo写文章
hexo new post 去XX旅游
hexo new post 常用工具整理
文件:source
└_post
├开始用hexo写文章.md
├去XX旅游.md
└常用工具整理.md
地址:https://waitung.cc/2017/11/16/开始用hexo写文章/
https://waitung.cc/2018/02/25/去XX旅游/
https://waitung.cc/2018/05/03/常用工具整理/
- 这样文章一多的时候
_posts
目录就会显得非常乱。
做法一:直接整理文章名字,只改动title: 文章标题
。hexo new post 001
hexo new post 002
hexo new post 003
文件:source
└_post
├001.md
├002.md
└003.md
地址:https://waitung.cc/2017/11/16/001/
https://waitung.cc/2018/02/25/002/
https://waitung.cc/2018/05/03/003/
这样一来,无法从文件名或者地址快速的知道这文章是写什么的。
- 不可取。
做法二:往文章名字加上日期。hexo new post 2017-11-16-开始用hexo写文章
hexo new post 2018-02-25-去XX旅游
hexo new post 2018-05-03-常用工具整理
文件:source
└_post
├2017-11-16-开始用hexo写文章.md
├2018-02-25-去XX旅游.md
└2018-05-03-常用工具整理.md
地址:https://waitung.cc/2017/11/16/2018-01-16-开始用hexo写文章/
https://waitung.cc/2018/02/25/2018-03-25-去XX旅游/
https://waitung.cc/2018/05/03/2018-05-03-常用工具整理/
比较满意_post
文件夹的整理,能对里面的文章进行排序,也可以从名字里知道文章写什么。但是文章地址上的日期重复显得很多余。
- 不可取。
做法三:修改/_config.yml
里的new_post_name
达到文章名字加上日期的效果。
默认:new_post_name: title.md
修改为:new_post_name: :year-:month-:day-:title.md
hexo new post 开始用hexo写文章
hexo new post 去XX旅游
hexo new post 常用工具整理
文件:source
└_post
├2017-11-16-开始用hexo写文章.md
├2018-02-25-去XX旅游.md
└2018-05-03-常用工具整理.md
地址:https://waitung.cc/2017/11/16/开始用hexo写文章/
https://waitung.cc/2018/02/25/去XX旅游/
https://waitung.cc/2018/05/03/常用工具整理/
- 比较满意的做法,也是我目前采用的做法。
做法四:做法三的改动,在_post
目录里再建立多一级的目录。
做法三:new_post_name: :year-:month-:day-:title.md
修改为:new_post_name: :year/:month-:day-:title.md
hexo new post 开始用hexo写文章
hexo new post 去XX旅游
hexo new post 常用工具整理
文件:source
└_post
├2017
│ └01-16-开始用hexo写文章.md
└2018
├02-25-去XX旅游.md
└05-03-常用工具整理.md
地址:https://waitung.cc/2017/11/16/开始用hexo写文章/
https://waitung.cc/2018/02/25/去XX旅游/
https://waitung.cc/2018/05/03/常用工具整理/
- 在方法三的基础再以年份把文章分开文件夹存放。
按不同需要还可以修改new_post_name
达到不同效果。
例:hexo new post post001
new_post_name: :year/:month/:title.md
\source\_post\2018\06\post001.md
new_post_name: :year-:month/:day-:title.md
\source\_post\2018-06\post001.md
还可以:new_post_name: :year/:month/:year-:month-:day-:title.md
\source\_post\2018\06\2018-06-18-post001.md
方便搜索用。
具体按照自身情况调整。
只有一条评论 (QwQ)
Nice~