'How to create "previous"/"next" links with custom, multi-level navigation in Jekyll?
I'm currently working on a Jekyll website containing some documentation. Said documentation is structured into discrete sublevels, using the following file structure:
root/
├─ category-1/
│ ├─ entry-1.md
│ ├─ entry-2.md
│ ├─ entry-3.md
├─ category-2/
│ ├─ entry-1.md
│ ├─ entry-2.md
│ ├─ entry-3.md
├─ category-3/
│ ├─ entry-2.md
│ ├─ entry-1.md
│ ├─ entry-3.md
To generate navigation links, I'm using a YAML data file containing a list of each category, and the entries it contains. It looks something like this:
navigation:
- name: Category 1
entries:
- Entry 1
- Entry 2
- Entry 3
- name: Category 2
entries:
- Entry 1
- Entry 2
- Entry 3
- name: Category 3
entries:
- Entry 1
- Entry 2
- Entry 3
Now, I'd like to implement buttons/links that could lead the user to the previous or next page, including ones from the previous or next category (i.e., category-1/entry-3/ would have a Next button leading to category-2/entry-1/). Ideally, I'd also want to display the name of the entry, without its category prepended to it.
I'm planning on hosting this website on GitHub Pages, so custom plugins are out of the questions, I can only use Liquid to deal with this.
I did find this question about a similar issue, but the OP only had to deal with single-level navigation, whereas mine has two levels. Still, using the code in the given answer, I was able to generate an array containing the names of each entry, but I also need to gather their category somehow. Is there any way I can achieve this? Any help would be greatly appreciated!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
