I\'m using Jekyll on GitHub pages, and I want to have hierarchical categories like this:
Modify your _config.yml accordingly
collections:
animals:
output: true
mammals:
output: true
cats:
output: true
dogs:
output: true
reptiles:
output: true
lizards:
output: true
then created the structure:
mkdir -p _animals/reptiles/lizards
mkdir -p _animals/mammals/cats
mkdir _animals/mammals/dogs
add your md files and all index.html which will index items with filter. It should look like this (maybe with more indexes) :
_animals/
├── index.html
├── mammals
│ ├── cats
│ │ ├── housecat.md
│ │ └── tiger.md
│ ├── dogs
│ │ ├── doberman.md
│ │ └── poodle.md
│ └── index.html
└── reptiles
└── lizards
├── chameleon.md
└── iguana.md
then you create _includes/list_animals.html
{% assign animals = site.animals| sort:'title' %}
{% for animal in animals %}
{% if page.url != animal.url and include.taxonomy == nil or animal.url contains include.taxonomy %}
{{animal.title}}
{% endif %}
{% endfor %}
to list all animals in animals/index.html
:
---
title: animals
---
{% include list_animals.html %}
For example, to list all mammals in animals/mammals/index.html
:
---
title: animals
---
{% include list_animals.html taxonomy="mammals" %}
Finally the generated structure should look like this (with some more index.html):
_site
└── animals
├── index.html
├── mammals
│ ├── cats
│ │ ├── housecat.html
│ │ └── tiger.html
│ ├── dogs
│ │ ├── doberman.html
│ │ └── poodle.html
│ └── index.html
└── reptiles
└── lizards
├── chameleon.html
└── iguana.html