Sorting
Use these options to customize the sorting of pages and sections. They affect all items that aren't explicitly ordered using nav
.
Child directories inherit these settings
Sorting options apply to all child directories as well, unless they're overridden by a .nav.yml
there.
Sort Direction
Use this option to change the direction from ascending to descending.
sort:
direction: desc
docs/
├─ .nav.yml
├─ getting-started.md
├─ support.md
└─ guides/
├─ authentication.md
└─ error-handling.md
- Support
- Getting started
- Guides
- Error handling
- Authentication
sort:
direction: asc
docs/
├─ .nav.yml
├─ getting-started.md
├─ support.md
└─ guides/
├─ authentication.md
└─ error-handling.md
- Getting started
- Support
- Guides
- Authentication
- Error handling
Sort Sections
By default, sections are always sorted after all pages. Use this option to have them before or mixed in with pages.
sort:
sections: first
docs/
├─ .nav.yml
├─ getting-started.md
├─ support.md
└─ guides/
├─ authentication.md
└─ error-handling.md
- Guides
- Authentication
- Error handling
- Getting started
- Support
sort:
sections: mixed
docs/
├─ .nav.yml
├─ getting-started.md
├─ support.md
└─ guides/
├─ authentication.md
└─ error-handling.md
- Getting started
- Guides
- Authentication
- Error handling
- Support
sort:
sections: last
docs/
├─ .nav.yml
├─ getting-started.md
├─ support.md
└─ guides/
├─ authentication.md
└─ error-handling.md
- Getting started
- Support
- Guides
- Authentication
- Error handling
Sort Type
awesome-nav
uses natural sorting by default. Set this option for strictly alphabetical sorting.
sort:
type: alphabetical
docs/
├─ version-9.0.md
├─ version-9.1.md
└─ version-10.0.md
- Version 10.0
- Version 9.0
- Version 9.1
sort:
type: natural
docs/
├─ version-9.0.md
├─ version-9.1.md
└─ version-10.0.md
- Version 9.0
- Version 9.1
- Version 10.0
Sort Ignore Case
Enable case-insensitive sorting.
Natural sorting
Note that natural
sorting (which is the default) already makes sure that lowercase and uppercase are grouped together.
Therefore the option makes most sense when combined with alphabetical
sorting.
sort:
ignore_case: true
type: alphabetical
docs/
├─ .nav.yml
├─ getting-started.md
├─ LICENSE.md
└─ support.md
- Getting started
- LICENSE
- Support
sort:
ignore_case: false
type: alphabetical
docs/
├─ .nav.yml
├─ getting-started.md
├─ LICENSE.md
└─ support.md
- LICENSE
- Getting started
- Support
Sort By
Configure which attribute is used for sorting.
Path & Filename
The difference between path
and filename
is only relevant with deep glob patterns, otherwise their behavior is identical.
sort:
by: filename
nav:
- "**/*.md"
docs/
├─ .nav.yml
├─ getting-started.md
├─ support.md
└─ guides/
├─ authentication.md
└─ error-handling.md
- Authentication
- Error handling
- Getting started
- Support
sort:
by: path
nav:
- "**/*.md"
docs/
├─ .nav.yml
├─ getting-started.md
├─ support.md
└─ guides/
├─ authentication.md
└─ error-handling.md
- Getting started
- Authentication
- Error handling
- Support
Title
Sort sections and pages based on their title instead of path or filename.
sort:
by: title
Limitation
Since MkDocs extracts the markdown title when it renders the page, it is not available when awesome-nav
is sorting the pages.
In order to have pages properly sorted by their title, add the title to the meta-data at the beginning of the markdown file:
---
title: Getting started
---
Without a title in the meta-data, sorting falls back to the filename.