Cheat Sheet
Material for MkDocs is packed with many great features that make technical writing a pleasure. This section of the documentation explains how to set up a page, and showcases all available specimen that can be used directly from within Markdown files.
Usage
Setting the page title
When [Metadata] is enabled, the page title can be overridden for a document with some custom front matter. Add the following lines at the top of a Markdown file:
- This will set the
titleinside the HTML document'sheadfor the generated page to this value. Note that the site title, which is set viasite_name, is appended with a dash.
Setting the page description
When [Metadata] is enabled, the page description can be overridden for a document with custom front matter. Add the following lines at the top of a Markdown file:
---
description: Nullam urna elit, malesuada eget finibus ut, ac tortor. # (1)!
---
# Document title
...
- This will set the
metatag containing the site description inside the documentheadfor the current page to the provided value.
Setting the page template
If you're using [theme extension] and created a new page template in the overrides directory, you can enable it for a specific page. Add the following lines at the top of a Markdown file:
Customization
Using metadata in templates
on all pages
In order to add custom meta tags to your document, you can [extend the theme ][theme extension] and [override the extrahead block][overriding blocks], e.g. to add indexing policies for search engines via the robots property:
{% extends "base.html" %}
{% block extrahead %}
<meta property="robots" content="noindex, nofollow" />
{% endblock %}
on a single page
If you want to set a meta tag on a single page, or want to set different values for different pages, you can use the page.meta object inside your template override, e.g.:
{% extends "base.html" %}
{% block extrahead %}
{% if page and page.meta and page.meta.robots %}
<meta property="robots" content="{{ page.meta.robots }}" />
{% else %}
<meta property="robots" content="index, follow" />
{% endif %}
{% endblock %}
You can now use robots exactly like title and description to set values. Note that in this case, the template defines an else branch, which would set a default if none was given.