As I started with this blog 2 years ago, I wanted to document the customization of Hexo to my needs in a series of articles. To group these articles I considered using the build-in
As it was freely available under a MIT license on Github, I forked it in July 2020 and made some bug fixes and drop a pull request to Levi … but he unfortunately never answered my pull or issue requests and has set the status of the project to DEPRECATED.
Ok then … make a successor on your own, fella…
Let me describe how the original plugin and my successor are working in general:
Assume, you have several posts from different authors and you want a list of all posts for every author. The only thing you have to do (after installation and configuration of the plugin), is to add a custom variable called
author to the FrontMatter of each post, with the name of the author as value.
title: My Fancy Post
Next time you run
hexo generate, several new files will be available in your output folder:
One INDEX page
… for the author index, with a list of all available authors and the number of the posts:
Many POSTS pages
…, one for each author for the author index, with all of the authors posts:
- /authors/ … /index.html
In order to avoid confusion (and be able to provide the plugin on Github/NPM) I needed a new name for the plugin and due to the fact that it is a generator, I named it simply hexo-generator-anything.
The original code was really hard to read, because every second variable was named ‘index’, therefore I started with some refactorings, before I continued implementing new features.
The original, one-dimensional variable to index mapping, wasn’t meaningful enough for me. The new mapping is now a dictionary and has unique identifiers:
template* setting names has changed into
layout_*, to make more clear what they are meant for. They are pointing to an existing EJS file in your Hexo themes layout folder to render the particular page.
EJS file (without extension) to render the INDEX page
EJS file (without extension) to render each POSTS page
titleSeparator setting is not longer available, because it is not necessary anymore. By providing a data structure for
index with the attributes
caption, a title can be put together in the EJS file itself.
One of my needs was, to provide more information on the INDEX page and the POSTS pages for each entry or, to stay with the example, for each author. As the
_posts folder is used for storing the post data files, I introduced a
_anything folder for dropping MD files, which are linked to the index and its values.
The subfolders of
_anything are representing the index and the files in it each possible value of the index.
The file is structured like any other post file: the FrontMatter data at the top and below some content to show along with the the entry to describe it:
The INDEX file itself may have its own Markdown file, to provide addition text or data to it, like describing the list.
title is a requirement in the Markdown files, but you can add as many variables as you need and use it in the EJS files. All data will be passed through to the template.