Package: mkdocs-awesome-pages-plugin
MkDocs Awesome Pages PluginAn MkDocs plugin that simplifies configuring page titles and their orderThe awesome-pages plugin allows you to customize how your pages show up the navigation of your MkDocs without having to configure the full structure in yourmkdocs.yml. It gives you detailed control using a small configuration file directly placed in the relevant directory of your documentation.Note:This plugin won't do anything if yourmkdocs.ymldefines anavorpagesentry. To make use of the features listed below, you'll either have to remove the entry completely oradd a...entry to it.InstallationNote:This package requires Python >=3.7 and MkDocs version 1.0 or higher.If you're still on MkDocs 0.17 useversion 1 of this plugin.Install the package with pip:pipinstallmkdocs-awesome-pages-pluginEnable the plugin in yourmkdocs.yml:plugins:-search-awesome-pagesNote:If you have nopluginsentry in your config file yet, you'll likely also want to add thesearchplugin. MkDocs enables it by default if there is nopluginsentry set, but now you have to enable it explicitly.More information about plugins in theMkDocs documentationFeaturesCustomize NavigationCreate a file named.pagesin a directory and use thenavattribute to customize the navigation on that level. List the files and subdirectories in the order that they should appear in the navigation.nav:-subdirectory-page1.md-page2.mdRestPages or sections that are not mentioned in the list will not appear in the navigation. However, you may include a...entry to specify where all remaining items should be inserted.nav:-introduction.md-...-summary.mdFurthermore, it is possible to filter the remaining items using glob patterns or regular expressions. For example to match only the Markdown files starting withintroduction-.nav:-... | introduction-*.md-...-summary.mdNote:The pattern is checked against the basename (folder- / filename) of remaining items - not their whole path.For more details refer to theRest Filter Patternssection below.TitlesYou can optionally specify a title for the navigation entry.nav:-...-First page:page1.mdNote:Specifying a title for a directory containing a.pagesfile that defines atitlehas no effect.LinksYou can also use thenavattribute to add additional links to the navigation.nav:-...-Link Title:https://lukasgeiter.comSectionsYou can group items by creating new sections.nav:-introduction.md-Section 1:-page1.md-page2.md-Section 2:-...Change Sort OrderCreate a file named.pagesin a directory and set theorderattribute toascordescto change the order of navigation items.order:descNote:Unlike the default order, this does not distinguish between files and directories. Therefore pages and sections might get mixed.Natural Sort TypeCreate a file named.pagesin a directory and set thesort_typeattribute tonaturalto usenatural sort order.This can be combined withorderabove.sort_type:naturalOrder Navigation By PreferenceCreate a file named.pagesin a directory and set theorder_byattribute tofilenameortitleto change the order of navigation items.order_by:titleThis can be combined withorderand/orsort_typeabove. Iforderis not set it will order ascending. If no preference is set, it will order by filename.Collapse Single Nested PagesNote:This feature is disabled by default. More on how to use it belowIf you have directories that only contain a single page, awesome-pages can "collapse" them, so the folder doesn't show up in the navigation.For example if you have the following file structure:docs/├─ section1/│  ├─ img/│  │  ├─ image1.png│  │  └─ image2.png│  └─ index.md# Section 1└─ section2/└─ index.md# Section 2The pages will appear in your navigation at the root level:Section 1Section 2Instead of how MkDocs would display them by default:Section 1IndexSection 2IndexFor all pagesCollapsing can be enabled globally using thecollapse_single_pagesoptioninmkdocs.ymlFor a sub-sectionIf you only want to collapse certain pages, create a file called.pagesin the directory and setcollapse_single_pagestotrue:collapse_single_pages:trueYou may also enable collapsing globally using the plugin option and then use the.pagesfile to prevent certain sub-sections from being collapsed by settingcollapse_single_pagestofalse.Note:This feature works recursively. That means it will also collapse multiple levels of single pages.For a single pageIf you want to enable or disable collapsing of a single page, without applying the setting recursively, create a file called.pagesin the directory and setcollapsetotrueorfalse:collapse:trueHide DirectoryCreate a file named.pagesin a directory and set thehideattribute totrueto hide the directory, including all sub-pages and sub-sections, from the navigation:hide:trueNote:This option only hides the section from the navigation. It will still be included in the build and can be accessed under its URL.Set Directory TitleCreate a file named.pagesin a directory and set thetitleto override the title of that directory in the navigation:title:Page TitleArrange PagesDeprecated:arrangewill be removed in the next major release -Usenavinstead.Create a file named.pagesin a directory and set thearrangeattribute to change the order of how child pages appear in the navigation. This works for actual pages as well as subdirectories.title:Page Titlearrange:-page1.md-page2.md-subdirectoryIf you only specifysomepages, they will be positioned at the beginning, followed by the other pages in their original order.You may also include a...entry at some position to specify where the rest of the pages should be inserted:arrange:-introduction.md-...-summary.mdIn this exampleintroduction.mdis positioned at the beginning,summary.mdat the end, and any other pages in between.Combine Custom Navigation & File StructureMkDocs gives you two ways to define the structure of your navigation. Either create a custom navigation manually inmkdocs.ymlor use the file structure to generate the navigation. This feature makes it possible to combine both methods. Allowing you to manually define parts of your navigation without having to list all files.Note:You can freely combine this with all the other features of this plugin. However they will only affect the part of the navigation that is not defined manually.Use thenaventry inmkdocs.ymlto define the custom part of your navigation. Include a...entry where you want the navigation tree of all remaining pages to be inserted.The following examples are based on this file structure:docs/├─ introduction.md├─ page1.md├─ page2.md└─ folder/├─ introduction.md├─ page3.md└─ page4.mdIf you wantedintroduction.md,page1.mdandpage2.mdto appear under their own section you could do this:nav:-Start:-page1.md-page2.md-summary.md-...Which would result in the following navigation:StartIntroductionPage 1Page 2FolderIntroductionPage 3Page 4The...entry can also be placed at a deeper level:nav:-page1.md-Rest:-...Which would result in the following navigation:Page 1RestIntroductionPage 2FolderIntroductionPage 3Page 4Furthermore, it is possible to filter the remaining items using glob patterns or regular expressions. For example to match only files namedintroduction.md.nav:-Introductions:-... | **/introduction.md-...With the following result:IntroductionsIntroductionIntroductionPage 1Page 2FolderPage 3Page 4Note:The pattern is checked against the path relative to the docs directory.For more details refer to theRest Filter Patternssection below.By default, remaining items keep their hierarchical structure. You may addflatto flatten all the matching pages:nav:-page1.md-Rest:-... | flat | **/introduction.md-... | flatPage 1RestIntroductionIntroductionPage 2Page 3Page 4Rest Filter PatternsIn all places where the rest entry (...) is allowed, you can also include a glob pattern or regular expression to filter the items to be displayed.nav:-... | page-*.md-... | regex=page-[0-9]+.mdThe filter only operates on remaining items. This means it will not include items that are explicitly listed in the navigation or items that are matched by another filter that appears earlier in the configuration.You may also include a rest entry without filter to act as a catch-all, inserting everything that is not matched by a filter.Syntax DetailsUnless the filter starts withregex=it is interpreted as glob pattern, however you may also explicitly say so usingglob=. The spaces around...are optional but recommended for readability.Note:Depending on the characters in your filter, you might also need to use quotes around the whole entry.nav:# equivalent glob entries-... | page-*.md-... | glob=page-*.md-...|page-*.md-'...|page-*.md'# equivalent regex entries-... | regex=page-[0-9]+.md-...|regex=page-[0-9]+.md-'...|regex=page-[0-9]+.md'OptionsYou may customize the plugin by passing options inmkdocs.yml:plugins:-awesome-pages:filename:.indexcollapse_single_pages:truestrict:falseorder:ascsort_type:naturalorder_by:titlefilenameName of the file used to configure pages of a directory. Default is.pagescollapse_single_pagesEnable the collapsing of single nested pages. Default isfalsestrictRaise errors instead of warnings when:arrangeentries cannot be foundnaventries cannot be foundDefault istrueorder,sort_typeandorder_byGlobal fallback values for the Meta attributes. Default isNoneorfilename.ContributingFrom reporting a bug to submitting a pull request: every contribution is appreciated and welcome.
Report bugs, ask questions and request features usingGithub issues.
If you want to contribute to the code of this project, please read theContribution Guidelines.