# hexo-generator-anything

> Hexo plugin to generate index pages from custom front matter variables

Latest version **2.0.0** (published 2025-07-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install hexo-generator-anything
pnpm add hexo-generator-anything
yarn add hexo-generator-anything
bun add hexo-generator-anything
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2025-07-18 |
| First published | 2021-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 32 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Kristof Zerbe |
| Maintainers | kristofzerbe |
| Keywords | hexo, index, generator, anything |

## Links

- npm: https://www.npmjs.com/package/hexo-generator-anything
- Repository: https://github.com/kristofzerbe/hexo-generator-anything
- Homepage: https://github.com/kristofzerbe/hexo-generator-anything#readme
- Issues: https://github.com/kristofzerbe/hexo-generator-anything/issues
- npm.io page: https://npm.io/package/hexo-generator-anything

## Dependencies (7)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [moment](https://npm.io/package/moment.md) ^2.29.4
- [hexo-fs](https://npm.io/package/hexo-fs.md) ^4.1.1
- [hexo-log](https://npm.io/package/hexo-log.md) ^3.2.0
- [hexo-util](https://npm.io/package/hexo-util.md) ^3.0.1
- [humanize-string](https://npm.io/package/humanize-string.md) ^2.1.0
- [hexo-front-matter](https://npm.io/package/hexo-front-matter.md) ^4.0.0

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2025-07-18
- 1.0.11 — 2022-12-05
- 1.0.10 — 2022-12-05
- 1.0.5 — 2021-06-10
- 1.0.4 — 2021-06-05
- 1.0.3 — 2021-04-26
- 1.0.2 — 2021-04-23
- 1.0.1 — 2021-04-22
- 1.0.0 — 2021-04-22

## README

[![GitHub package.json version](https://img.shields.io/github/package-json/v/kristofzerbe/hexo-generator-anything?label=version&style=flat-square)](https://github.com/kristofzerbe/hexo-generator-anything/blob/main/package.json)
[![issues](https://img.shields.io/github/issues/kristofzerbe/hexo-generator-anything?label=github%20issues&style=flat-square)](https://github.com/kristofzerbe/hexo-generator-anything/issues)
[![npm](https://img.shields.io/npm/dm/hexo-generator-anything?label=npm%20downloads&style=flat-square)](https://www.npmjs.com/package/hexo-generator-anything)

# hexo-generator-anything

**Hexo plugin to generate index pages from custom front matter variables.**

> :information_source: This project is a fork from [hexo-index-anything](https://github.com/leviwheatcroft/hexo-index-anything) by Levi Wheatcroft, who is no longer maintaining the project. I have refactored the code and introduced some new features ... see below.

## Introduction

Suppose you have an **author** variable in your front matter, this plugin will generate an **overview page** of all authors (called MAIN INDEX) and for each author, a listing page with all posts by that author (POSTS INDEX).

You can define multiple indexes to be created, by configuring several ``index_mappings`` out of your Frontmatter variables (see Configuration).

### Example

The Frontmatter data of the following two posts...

**../source/_posts/post-1.md**

``` md
---
title: First Post
author: Maria
---
```

**../source/_posts/post-2.md**

``` md
---
title: Second Post
author: Jonas
---
```

**../source/_posts/post-3.md**

``` md
---
title: Third Post
author: Jonas
---
```

... will lead to:
- ``../output/author/index.html``  
MAIN INDEX file with a link list of all authors

- ``../output/author/maria.html``  
POSTS INDEX file with list of all posts from Maria, here 'First Post' only

- ``../output/author/jonas.html``  
POSTS INDEX file with list of all posts from Jonas, here 'Second Post' and 'Third Post'

If you have activated the Hexo configuration attribute [``post_asset_folder``](https://hexo.io/docs/asset-folders.html), then the output will be:

- ``../output/author/index.html``
- ``../output/author/maria/index.html``
- ``../output/author/jonas/index.html``

## Installation

You'll find the package at [npm/hexo-generator-anything](https://www.npmjs.com/package/hexo-generator-anything). For installation just tun following command in your console:

``npm install hexo-generator-anything --save``

## Configuration

### _config.yml

To configure the plugin, add following section to your Hexo's root ``_config.yml``:

```yml
anything:
  defaults:
    layout:
      main: anything-main
      posts: anything-posts
  index_mappings:
    - variable: author
      path: author
    - variable: example
      path: example
      layout:
        posts: anything-posts-example
    - variable: another-variable
      path: others
      skip_main: true

```

The settings in depth:

| Settings | Description |
|---------|------------|
| layout.main | EJS template for processing MAIN INDEX file<br>(if not set, Hexo's default ``index.ejs`` will be used) |
| layout.posts | EJS template for processing POSTS INDEX file<br>(if not set, Hexo's default ``index.ejs`` will be used) |
| index_mappings | List of Anything mappings |
| ... variable | Frontmatter variable in your posts to generate an index of |
| ... path | Part of the path of the output files, which represents the index |
| ... layout.[main\|posts] | Override default layout EJS template for this mapping |
| ... skip_main | Skip rendering of MAIN INDEX, including the folder |

You can find examples for ``layout_main.ejs`` and ``layout_posts.ejs`` (and their partials) in the package ``samples`` folder under ``/node_modules/hexo-generator-anything/`` after installation. Place the files in your Hexo's layout folder.

### Skipping the MAIN INDEX

By using ``skip_main = true`` on a mapping you can suppress the generation of the MAIN INDEX and the main folder itself. The output will be:

- ``../output/maria/index.html``
- ``../output/jonas/index.html``

### Additional Markdown Files

For generating the POSTS INDEX page, you can enrich the information about each author (variable value = key), by providing a Markdown file in in your sources folder: ``../source/_anything/{index}/{key}``.

To stay with the example above, we have in index called ``authors`` and two keys: ``maria`` and ``jonas``:

``` txt
|- source
|  |- _anything
|  |  |- authors
|  |  |  |-> maria.md
|  |  |  |-> jonas.md 
```

Each of these files has to have at least one Frontmatter variable called ``title``, where you can overwrite the default key string (value of the index variable in the posts). You can extend the Frontmatter with as many variables as you want and use it in your POSTS INDEX EJS template.

The content of the MD file will also be available in the data for generating the POSTS INDEX page.

Example:

```md
---
title: Marias Posts
avatar: ./photos/maria.jpg
email: maria@my-domain.com
---

Maria is writer of the month. Don't miss her tweets on [https://twitter.com/maria](https://twitter.com/maria)
```

The MAIN INDEX page, may have a linked Markdown file too, to provide content or additional data:

```txt
|- source
|  |- _anything
|  |  |- authors
|  |  |  |-> index.md
|  |  |  |-> ...
```

## Usage

Install, configure, then run `hexo generate` as usual.

## Contributing

Yes, please ... fork the project, make your changes and submit pull requests against the main branch.

## Demo

I have created this project for my blog and I use it to group some posts into series. You can see the result at: [**https://kiko.io/series**](https://kiko.io/series)

## More Information

I have a section for this project on my blog with posts regarding this project (automatically generated by this plugin ;) at [**http://kiko.io/projects/hexo-generator-anything**](http://kiko.io/projects/hexo-generator-anything)

## History

**2.0.0**

- New configuration structure (Breaking Change)
- New configuration feature '{mapping}.layout.[main|posts]' to override the default template for a particular mapping
- New configuration feature '{mapping}.skip_main' to suppress generation of MAIN INDEX
- Code refactoring to make it more understandable

**1.0.5**

- Path fix (Lowercase)

**1.0.4**

- Replaced vulnerable string.js library

**1.0.3**

- Refactorings
- Introducing Markdown file for INDEX page
- ``titleSeparator`` setting removed
- Updated samples

**1.0.1/2**

- Markdown data fix

**1.0.0**

- Initial version

## License

**MIT** : http://opensource.org/licenses/MIT

## Codebase Vizualization
For an inactive diagram, please visit [Repo Visualization App](https://octo-repo-visualization.vercel.app/?repo=kristofzerbe%2Fhexo-generator-anything)...
![Visualization of the codebase](./DIAGRAM.svg)

---
_Source: https://npm.io/package/hexo-generator-anything · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
