hexo next 为文章添加分类

hexo next 添加分类页

  1. 新建一个页面,命名为 categories 。命令如下:

    hexo new page categories
    
  2. 编辑刚新建的页面,将页面的类型设置为 categories ,主题将自动为这个页面显示所有分类。

    title: 分类
    date: 2014-12-22 12:39:04
    type: "categories"
    ---
    

    注意:如果有启用多说 或者 Disqus 评论,默认页面也会带有评论。需要关闭的话,请添加字段 comments 并将值设置为 false,如:

    title: 分类
    date: 2014-12-22 12:39:04
    type: "categories"
    comments: false
    ---
    
  3. 在菜单中添加链接。编辑主题的 _config.yml ,将 menu 中的 categories: /categories 注释去掉,如下:

    menu:
      home: /
      categories: /categories
      archives: /archives
      tags: /tags
    
  4. 但是这样部署之后,在分类页面还是看不到任何分类的,同时官方的next教程中并没有写。。
    其实为文章添加分类关联的教程已经在hexo教程给出了。。
    下面仅仅做个简单的介绍,全面的教程参照hexo官方教程(需备梯子)

添加文章分类关联

  1. hexo中有Front-matter这个概念,是文件最上方以 — 分隔的区域,用于指定个别文件的变量。举个栗子,在hexo new post article时会生成article.md文件,文件生成好的文章属性。

    ---
    title: hexo next 为文章添加分类
    date: 2016-03-16 08:12:43
    tags:
    ---
    
  2. 在其中添加categories属性,再部署之后就可以在分类页看到分类了

    ---
    title: hexo next 为文章添加分类
    date: 2016-03-16 08:12:43
    tags:
    categories: 前端
    ---