Automate mkdocs nav generation #157
Labels
feature-request
Request for functionality that has not already been implemented
question
Something that requires more information before moving forward
tooling
Related to tools and utilities for the management of the project
Background
mkdocs currently allows two ways to generate its navigation: automated and manual. (See mkdocs navigation docs)
Automated
When the
nav
entry is absent from the mkdocs configuration file (default:mkdocs.yml
), the entire documentation directory (default:docs/
) is parsed and looks for files with a valid markdown extension to generate a navigation with section headers for each folder and documents for each markdown file.Example
With no
nav
entry in the mkdocs configuration file and a directory structure like this:mkdocs will generate a navigation menu like this:

Manual
Allows a
nav
entry to be put into the mkdocs configuration file to specify the files/sections included in the navigations as well as their order however all files must be explicitly configured.Example:
With a directory structure like this:
And a configuration file containing a
nav
section like this:mkdocs will generate a navigation menu like this:

Note that the directory structure is the same, files note explicitly configured in the
nav
section are ignored.Problem
The automated method of navigation generation allows for all files to be included in the navigation with little effort but allows no control over order. The manual method of navigation generation allows for control over order but requires all files to be linked to manually.
For documentation, the ability to order documents is important as the flow of information implies where to start and allows for a path to be made showing others how to use whatever is being documented. Therefore, the ability to control document order is imperative. However, the overhead of manually linking to every new document is cumbersome and presents a barrier both to documentation maintenance and third party contribution.
We need a way to control the order of documents while also automating the generation of the navigation menu.
Work So Far
This is an issue that the greater mkdocs community is already aware of as evident in this GItHub issue requesting the same feature The useful suggestions from this thread include:
I spent a few days creating a script inspired by the nav generation script with slow but promising success before seeing the plugin mentioned. The plugin claims to achieve the same outcome with a different approach. If it actually works, processing with the plugin makes more sense than writing our own tool. However, if the management of the plugin still proves more difficult than helpful we will fall back to developing our own tool.
The text was updated successfully, but these errors were encountered: