Skip to main content

A simple mkdocs plugin, enables to organize Navigation in a more markdownic way.

Project description

mkdocs-nav-weight

中文

[!NOTE]

If you are looking for a suitable Markdown editor, or are using Obsidian, then there is a plugin with basically the same functionality available here.

A simple MkDocs plugin that allows page sorting, section sorting, and page visibility in the navigation to be controlled through additional keywords added to the dds Markdown Metadata (or front-matter) of your docs.

This plugin emulates functionality found in other static site generators like Hugo and provides a more natural, markdownic way to control the order of your pages in an MkDocs site. Page order is set using the weight keyword which controls the relative order of the doc when compared to other docs in the same folder.

title: Getting Started - Some Topic
description: A First Tutorial on Something Important
weight: 1

A page you want to appear after the page above would have a higher weight value.

title: Next Steps - Some Topic
description: A Second tutorial that needs to come after the first
weight: 2

Additional keywords (described below) control the visibility of the page in the nav, the name of the section, and the order the sections appear.

This plugin will read the keywords from each markdown file during the build process and therefore may add some performance overhead on building.

Usage

This plugin enables four additional keywords in the MkDocs Markdown Metadata.

Keyword Datatype Default Value Applies to Description
weight number 0 All markdown files Controls the relative order of the page in the folder, with pages sorted from lowest weight to highest. For index.md files, this weight is used to order the sections (folders) at the folder level. If the weight keyword is not included for a page, it will be assigned a default weight of 0 or the value of the default_page_weight property set in the mkdocs.yml file as described below.
headless bool false All markdown files Controls if the page is hidden from the nav. Pages hidden from the nav are still accessible by directly navigating to the URL. For index.md files, this keyword controls the visibility of the section (folder) in the nav
retitled bool false index.md files only Indicates that the section should use the title value of the index.md file rather than the folder name. This allows you to rename sections into friendlier names that typical directory named. This option is ignored if the property section_renamed is set to true in the mkdocs.yml file (see below). In this case, all pages will be retitled using the title value in their respective index.md file.
empty bool false index.md files only Indicates that the index.md file does not contain any content, only metadata. If set to true, the index.md file will not appear in the nav and only be used to provide metadata about the section (such as the weight and title of the section).

Installation

Install with pip:

pip install mkdocs-nav-weight

Add the following lines to mkdocs.yml

plugins:
  - search
  - mkdocs-nav-weight

Configuration Options

Configure in mkdocs.yml:

plugins:
  - search
  - mkdocs-nav-weight:
      section_renamed: false
      index_weight: -10
      warning: true
      reverse: false
      headless_included: false
      default_page_weight: 1000
Parameter Default Value Description
section_renamed false When true, the section name will use the title of its index.md page instead of the folder name. For example, you may have a folder named csharp but want the name of the section to be C#. Setting this parameter to true enables this behavior.
index_weight -10 The weight value to use for the index.md page to ensure it's always shown first in the folder. All other pages in the folder should have weight values greater than this value (so they will be listed after the index.md page).
default_page_weight 0 The default weight assigned to each page (when the page does not contain a weight value). If you want pages without a weight value to be sorted at the end, set this value to a high number (example: 1000).
reverse false By default, pages are sorted from lowest weight value to highest. Setting this value to true will sort pages from highest to lowest.
headless_included false An option to control whether headless pages should be included in nav.pages which is used by some plugins, eg: mkdocs-pdf-export-plugin.
warning true Controls whether to send a Warning when invalid values are detected in markdown metadata.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs_nav_weight-0.3.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_nav_weight-0.3.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_nav_weight-0.3.0.tar.gz.

File metadata

  • Download URL: mkdocs_nav_weight-0.3.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for mkdocs_nav_weight-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e4b66f0693aa1d8b82876727f3c5a6aa3c85834069dfd1b5ea23432ff3d862bb
MD5 a12124c4bd762c4f6bf38e18ac6222af
BLAKE2b-256 94081b996d23571758287ee4098e16779d2b44b58005dc2b80f20423774d7ce5

See more details on using hashes here.

File details

Details for the file mkdocs_nav_weight-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_nav_weight-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f95b2f2ca3f3125e95c4518ed66df4a1b9082d37840b352a5a3e3c2559276cba
MD5 84651273d0a30ae00ffce4f4b04e22a2
BLAKE2b-256 47ec12153ca0b5821b8a0a443431da7427df21a3566a96410e744b7cb62465c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page