Metadata
Description¶
Every MkPage as well as every MkNav can carry metadata. Page metadata inherits from Nav metadata, similarly as the MkDocs-Material meta plugin.
Metadata can be set either via the MkPage constructor, via the MkNav.route.page decorator. Also, some methods like MkNav.parse.folder take metadata keyword arguments in order to set it for all parsed pages.
Examples¶
Via decorators:
Via constructor:
Metadata fields¶
The Metadata class is a subclassed Python dictionary.
It is enhanced with properties for common metadata fields in order to get proper type hints. Since this object is a dict subclass, you can of course also add any non-documented stuff to the Metadata.
exclude_from_search
property
writable
¶
Exclude this page from search.
hide
property
writable
¶
A list of items which should be hidden from the page.
MkDocs-Material supports "navigation", "toc", "path", "tags".
render_macros
property
writable
¶
Whether this page should get rendered by the templating engine.
search
property
writable
¶
A dictionary containing search-related settings ("boost" / "exclude").
search_boost
property
writable
¶
A multiplier to modify search relevance.
status
property
writable
¶
The status of the page.
MkDocs-Material supports "new", "deprecated" and "encrypted" by default
by showing an icon in the site nav. Additional icons can be added during
the build process via MaterialTheme.add_status_icon().
template
property
writable
¶
Filename of the template the page should use.
This is only a reference, you still need to add the template to the theme.
as_page_header
¶
Format metadata in Page header format (with --- separators).
parse
classmethod
¶
Parse given text for metadata and return a (Metadata, Rest-from-text) tuple.