mkdocsmkdocs-material

Can I influence the order of directories and pages in mkdocs/mkdocs-material manually?


In this example, I have a book-like documentation and it has three chapters:

These would go into separate directories (with sub-pages each ...). The file layout would look like this:

doc/
  advanced-use/
  basic-use/
  intro/

By default, mkdocs and mkdocs-material will order alphabetically, so chapters would end up in the order shown in the file layout above.

Things I know about, but would like to avoid:

I am looking for a way similar to jekyll's/just-the-docs' nav_order variable, which can be specified in the frontmatter metadata.


Solution

  • I found a plugin to mkdocs that does exactly what I was looking for:

    mkdocs-nav-weight

    You add a weight property to your frontmatter, and it takes care of sorting the navigation. It even keeps "previous"/"next" intact. It also deals with section index pages out of the box.