Package: mkdocs-add-number-plugin
mkdocs-add-number-pluginMkDocsplugin to automatically number the headings (h1-h6) in each markdown page and the nav. This only affects your rendered HTML and does not affect the markdown files.Setupuse pip3Install the plugin using pip3:pip3installmkdocs-add-number-pluginbuild from sourceuse git clone the source code to your computer and execute commands:cdmkdocs-add-number-plugin
mkdirwheelscdwheels# if you have installed the plugin, uninstall it.# pip3 uninstall mkdocs-add-number-plugin -ypip3wheel..
pip3installmkdocs_add_number_plugin-*-py3-none-any.whlNext, add the following lines to yourmkdocs.yml:plugins:
  - search
  - add-numberIf 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.UsageExample of multiple options set in themkdocs.ymlfile:plugins:
    - search
    - add-number:
        strict_mode: False
        order: 1
        excludes: 
        	- sql/
        	- command/rsync
        includes:
        	- sql/MySQLNote that each title in your markdown page must be contain a space after the heading tag:# titleis correct, but#titlewill cause an error.Optionsstrict_mode:When set toFalse(default), orders the title numbers in your HTML page sequentiallyWhen set toTrueit will follow the headings order strictly. You must start writing documents from h1, and cannot skip headings (such as# title1\n### title2\n).order: Heading level to start counting (number). Default is1. Example use case: When you want to use the first title of a document as the title of a document and you don't want to number it, set it toorder: 2.excludes: Exclude certain files or folders in thedocs/folder. Default is None. To exclude entire folders, append a slash (folder/).includes: The syntax is similar toexcludesand it meant to be used together. You could for example exclude an entire folder but include several files from that folder.increment_topnav: Number top-level navigation.increment_pages: Number secondary navigation.Example of usingexcludesFor example, there is a mkdocs directory structure as follows:$tree.
.
├──docs
│├──command││├──rsync.md
││├──sed.md|...
└──mkdocs.ymlTo exclude rsync file, add the excludes option as follows:plugins:-search-add-number:excludes:-command/rsyncIf you want to exclude the command folder, add the excludes option as follows:plugins:-search-add-number:excludes:-command/Example of usingincrement_topnavNumber top-level navigation :increment_topnav:True|FalseThe deault value isFalse.note: Bothincludesandexcludesoptions don't affect this option.Effect after enabling:Example of usingincrement_pagesNumber secondary navigation :increment_pages:True|FalseThe deault value isFalse.note: Bothincludesandexcludesoptions don't affect this option.Effect after enabling:Example of usingincrement_topnavwithincrement_pagesWhen both are turned on at the same time, the numbering effect of the secondary navigation is affected------ CHINESE VERSION ------mkdocs-add-number-plugin一个mkdocs插件：为你的每个页面的标题（h1~h6）自动编号。这只影响你的html渲染结果，并不影响markdown文档本身！安装使用 pip 安装# if you have installed the plugin, uninstall it.# pip3 uninstall mkdocs-add-number-plugin -ypip3installmkdocs-add-number-plugin从源码构建安装克隆此项目到你的计算机上，然后执行以下命令：cdmkdocs-add-number-plugin
mkdirwheelscdwheels# if you have installed the plugin, uninstall it.# pip3 uninstall mkdocs-add-number-plugin -ypip3wheel..
pip3installmkdocs_add_number_plugin-*-py3-none-any.whl使用在mkdocs.yml文件中的plugins选项添加此插件：plugins:-search-add-number:strict_mode:Falseorder:1excludes:-sql/- command/rsyncincludes:-sql/MySQL提供的选项strict_modeorderexcludesincludesincrement_topnavincrement_pagesstrict_mode指定编号的模式。语法：strict_mode:True|FalseTrue：严格模式。顺序地为你的html页面的标题编号。必须从h1开始撰写文档，且不能有跳级（比如# title1\n### title2\n，title2不会被编号，可以选用非严格模式为其编号），但是可以不必用到所有级数。False：非严格模式（默认值）。顺序地为你的html页面的标题编号。没有上述的限制。注意：两种模式的标题级数都不能有倒序出现。比如### title1\n# title2\n，这会导致编号异常。并且每个标题后面都要有空格与文字隔开，比如这样# title是正确的，而这样#title是不行的。效果非严格模式效果：严格模式效果：order从第几个标题开始编号。在某些场景下是有用的：你想要将文档的第一个标题作为文档的题目而不想对其进行编号时，设置为order: 2。语法：order:数字数字必须是大于1的自然数，默认值是1。excludes排除某些文件或文件夹。语法：excludes:列表|'*'列表：遵循yaml文件的列表语法，文件或文件夹填写docs文件夹下的相对路径，不必填写文件后缀。以/或\结尾的值表示文件夹。'*'：表示排除所有的文件。因为默认值为空列表[]，意味着对所有的文件进行编号，所以你需要使用此值来不对所有的文件进行编号。例子比如现在有一 mkdocs 目录结构如下：$tree.
.
├──docs
│├──command││├──rsync.md
││├──sed.md|...
└──mkdocs.yml想要排除rsync文件，添加的excludes选项如下：plugins:-search-add-number:excludes:-command\rsync若想要排除command文件夹，添加的excludes选项如下：plugins:-search-add-number:excludes:-command\includes包含某些文件或文件夹。语法与excludes类似：includes:列表在被excludes排除的文件或文件夹如果在includes选项中出现，那么会对其进行编号。默认值为空列表[]。注意：includes是作为excludes的辅助选项使用的（意味着必须和excludes一起使用，单独使用此选项没有意义）。increment_topnav对顶级目录索引进行编号。语法：increment_topnav:True|False默认值为 False。注意：includes和excludes选项不会影响此选项。开启之后的效果：increment_pages对二级目录索引进行编号。语法：increment_pages:True|False默认值为 False。注意：includes和excludes选项不会影响此选项。开启之后的效果：increment_topnav 与 increment_pages 共用两者同时开启时会影响二级目录索引的编号效果：