I would like to group categories in hexo. While the hexo <% list_categories %> helper lists all my categories alright, I would like to group nested categories right.
My question is on two levels, first, how do you represent the subcategories in the front matter. In other words, how would I add the subcategories [motosport, cricket, basketball, hockey] into the following front matter. sports is the main category
categories:
- sports
Two, how do I enumerate through all categories and each of their children. Do I still use this code
<%- list_categories(site.categories, { options}); %>
or is there a better way/function?
In Hexo v3.3.9 added hierarchical categories feature. Need to update
hexo/node_modules/hexo/lib/models/post.js
by this commit (or newer if exists). And set categories like this (in*.md
):<%- list_categories() %>
without any parameters enumerate parents and their childs already in hierarchical list;<%- list_categories(site.categories, {depth: 1}) %>
enum only parents (sport) of site total, etc. Full options for now here.