Skip to content

How to use custom HTML/Jinja2 template per page

mkdocs-material handles template YAML frontmatter property. For instance, we have a templates/announce.html template file which we want to use on this page. To use it, we can write:
template: announce.html

Markdown content…

mkdocs-material:template RDF property

Alternatively, we can state the following anywhere in the site.

$id: local:material/
mkdocs-material:template: announce.html

Assign custom template to multiple pages at once

Use the power of đŸ¦‰ OWL.

$id: PageWithCustomTemplateClass
  $type: owl:Restriction
    $id: mkdocs-material:template
    $id: custom_template.html

Then, you need to ensure that each page in question has PageWithCustomTemplateClass assigned. This can be done via $type declaration or perhaps with more OWL magic.