Skip to content

Add page trees to MkDocs

Issue

While browsing this wiki on my phone, I noticed that navigating subpages of a category is not intuitive. If there is a index page for the category, you have to open the sidebar again to select the subpage. Thus, I was looking for a solution to this problem.

Solution

The easiest one is to just display all subpages in the index page of the category. However, MkDocs does not provide a native way to do this. Luckily, there is a relatively unknown plugin called mkdocs-pagetree-plugin that can tackle this issue. It displays subpages in a tree structure, including the category names. This plugin is tested for the default MkDocs theme, as well as Material for MkDocs.

Check out the documentation on how to use the plugin: https://tombreit.github.io/mkdocs-pagetree-plugin/

Example

This is the page tree of this wiki: