HEXO plugin:hexo-generator-anything

A hexo plugin to generate any index pages based on meta info of posts. Similar to hexo-generator-categories, but has more space to customize.

Abstract

The plugin metioned in this post is hexo-generator-anything,

1
2
3
Suppose you have an author variable in your front matter, 
this plugin will generate an overview page of all authors (called INDEX) and for each author,
a listing page with all posts by that author (POSTS).

The result can refer to this blog’s Series page, as you can see, I created this to manually collect some relevant posts into one post-like item.

It can also used for the different authors(like the author of this plugin mentioned), or some internal-connection labels of posts like tag but can’t, or not appropriate to be described as tag.

Usage

To make this more plain, just think it like another categories.

First, add a item into the post you want to index, like this

1
2
3
index_name:
- val1
- val2

then, create a _anything directory and files into your blog’s source dir, if you want to write a detailed description for some value, you can touch a value_name.md file like you put in /about/index.md.

Then, append these code in the _config.yml of the blog.

1
2
3
4
5
6
anything:
layout_index:
layout_posts:
index_mappings:
- variable: index_name
path: index_name

At last, clean, regenerate as usual, then you can have a cutomized categories.

Notice, the index you created will not be displayed in the menu bar unless you add a item in the _config.yml of the theme you used.

1
2
menu:
index: /index_name/ || icon