2020-07-22 14:37:14 +03:00
|
|
|
|
---
|
|
|
|
|
template: overrides/main.html
|
|
|
|
|
---
|
|
|
|
|
|
2021-12-16 19:08:57 +03:00
|
|
|
|
# Reference
|
2020-07-22 14:37:14 +03:00
|
|
|
|
|
2021-12-16 19:08:57 +03:00
|
|
|
|
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.
|
2020-07-27 15:44:47 +03:00
|
|
|
|
|
2020-07-22 14:37:14 +03:00
|
|
|
|
## Configuration
|
|
|
|
|
|
2022-09-27 16:37:26 +03:00
|
|
|
|
### Built-in meta plugin
|
2022-07-17 16:20:08 +03:00
|
|
|
|
|
|
|
|
|
[:octicons-heart-fill-24:{ .mdx-heart } Sponsors only][Insiders]{ .mdx-insiders } ·
|
|
|
|
|
[:octicons-tag-24: insiders-4.21.0][Insiders] ·
|
|
|
|
|
:octicons-cpu-24: Plugin ·
|
|
|
|
|
:octicons-beaker-24: Experimental
|
|
|
|
|
|
|
|
|
|
The built-in meta plugin allows to __set front matter per folder__, which is
|
|
|
|
|
especially handy to ensure that all pages in a folder use specific templates or
|
|
|
|
|
tags. Add the following lines to `mkdocs.yml`:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
plugins:
|
2022-09-12 19:11:47 +03:00
|
|
|
|
- meta # (1)!
|
2022-07-17 16:20:08 +03:00
|
|
|
|
```
|
|
|
|
|
|
2022-09-12 19:11:47 +03:00
|
|
|
|
1. Note that the meta plugin should be located at the beginning of the list
|
|
|
|
|
of `plugins`, so that other plugins (including the [built-in blog plugin])
|
|
|
|
|
will pick up the set defaults.
|
|
|
|
|
|
2022-07-17 16:20:08 +03:00
|
|
|
|
> If you need to be able to build your documentation with and without
|
|
|
|
|
> [Insiders], please refer to the [built-in plugins] section to learn how
|
|
|
|
|
> shared configurations help to achieve this.
|
|
|
|
|
|
|
|
|
|
The following configuration options are available:
|
|
|
|
|
|
2022-09-11 20:25:40 +03:00
|
|
|
|
[`meta_file`](#+meta.meta_file){ #+meta.meta_file }
|
2022-07-17 16:20:08 +03:00
|
|
|
|
|
|
|
|
|
: :octicons-milestone-24: Default: `**/.meta.yml` – This option specifies the
|
|
|
|
|
name of the meta files that the plugin should look for. The default setting
|
|
|
|
|
assumes that meta files are called `.meta.yml`:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
plugins:
|
|
|
|
|
- meta:
|
|
|
|
|
meta_file: '**/.meta.yml' # (1)!
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
1. Note that it's strongly recommended to prefix meta files with a `.`,
|
|
|
|
|
since otherwise they would be included in the build output.
|
|
|
|
|
|
2022-09-12 19:11:47 +03:00
|
|
|
|
[built-in blog plugin]: ../setup/setting-up-a-blog.md#built-in-blog-plugin
|
2022-07-17 16:20:08 +03:00
|
|
|
|
[built-in plugins]: ../insiders/getting-started.md#built-in-plugins
|
|
|
|
|
|
2020-07-27 14:50:31 +03:00
|
|
|
|
## Usage
|
2020-07-22 20:11:22 +03:00
|
|
|
|
|
2020-07-23 18:00:20 +03:00
|
|
|
|
### Setting the page title
|
2020-07-22 20:11:22 +03:00
|
|
|
|
|
2022-08-13 11:57:43 +03:00
|
|
|
|
The page title can be overridden for a document with the front matter `title`
|
|
|
|
|
property. Add the following lines at the top of a Markdown file:
|
2020-07-22 20:11:22 +03:00
|
|
|
|
|
2022-09-11 20:25:40 +03:00
|
|
|
|
``` yaml
|
2020-07-23 18:00:20 +03:00
|
|
|
|
---
|
2021-12-11 16:30:07 +03:00
|
|
|
|
title: Lorem ipsum dolor sit amet # (1)!
|
2020-07-23 18:00:20 +03:00
|
|
|
|
---
|
2021-05-30 16:59:13 +03:00
|
|
|
|
|
|
|
|
|
# Document title
|
|
|
|
|
...
|
2020-07-22 20:11:22 +03:00
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 14:17:39 +03:00
|
|
|
|
1. This will set the [`title`][title] inside the HTML document's [`head`][head]
|
|
|
|
|
for the generated page to this value. Note that the site title, which is set
|
|
|
|
|
via [`site_name`][site_name], is appended with a dash.
|
2020-07-22 20:11:22 +03:00
|
|
|
|
|
2021-10-10 14:17:39 +03:00
|
|
|
|
[title]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
|
|
|
|
|
[head]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head
|
|
|
|
|
[site_name]: https://www.mkdocs.org/user-guide/configuration/#site_name
|
2020-07-27 14:50:31 +03:00
|
|
|
|
|
2020-07-23 18:00:20 +03:00
|
|
|
|
### Setting the page description
|
2020-07-22 20:11:22 +03:00
|
|
|
|
|
2022-08-13 11:57:43 +03:00
|
|
|
|
The page description can be overridden for a document with the front matter
|
|
|
|
|
`description` property. Add the following lines at the top of a Markdown file:
|
2020-07-22 20:11:22 +03:00
|
|
|
|
|
2022-09-11 20:25:40 +03:00
|
|
|
|
``` yaml
|
2020-07-23 18:00:20 +03:00
|
|
|
|
---
|
2021-12-16 19:08:57 +03:00
|
|
|
|
description: Nullam urna elit, malesuada eget finibus ut, ac tortor. # (1)!
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# Document title
|
|
|
|
|
...
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
1. This will set the `meta` tag containing the site description inside the
|
|
|
|
|
document `head` for the current page to the provided value.
|
|
|
|
|
|
|
|
|
|
### Setting the page icon
|
|
|
|
|
|
2022-05-05 14:33:14 +03:00
|
|
|
|
[:octicons-heart-fill-24:{ .mdx-heart } Sponsors only][Insiders]{ .mdx-insiders } ·
|
2021-12-16 19:08:57 +03:00
|
|
|
|
[:octicons-tag-24: insiders-4.5.0][Insiders] ·
|
|
|
|
|
:octicons-beaker-24: Experimental
|
|
|
|
|
|
|
|
|
|
An icon can be assigned to each page, which is then rendered as part of the
|
2022-08-13 11:57:43 +03:00
|
|
|
|
navigation sidebar. Add the following lines at the top of a Markdown file:
|
2021-12-16 19:08:57 +03:00
|
|
|
|
|
2022-09-11 20:25:40 +03:00
|
|
|
|
``` yaml
|
2021-12-16 19:08:57 +03:00
|
|
|
|
---
|
|
|
|
|
icon: material/emoticon-happy # (1)!
|
2020-07-23 18:00:20 +03:00
|
|
|
|
---
|
2021-05-30 16:59:13 +03:00
|
|
|
|
|
|
|
|
|
# Document title
|
|
|
|
|
...
|
2020-07-22 20:11:22 +03:00
|
|
|
|
```
|
|
|
|
|
|
2022-01-16 19:27:14 +03:00
|
|
|
|
1. Enter a few keywords to find the perfect icon using our [icon search] and
|
|
|
|
|
click on the shortcode to copy it to your clipboard:
|
|
|
|
|
|
|
|
|
|
<div class="mdx-iconsearch" data-mdx-component="iconsearch">
|
|
|
|
|
<input class="md-input md-input--stretch mdx-iconsearch__input" placeholder="Search icon" data-mdx-component="iconsearch-query" value="emoticon happy" />
|
|
|
|
|
<div class="mdx-iconsearch-result" data-mdx-component="iconsearch-result" data-mdx-mode="file">
|
|
|
|
|
<div class="mdx-iconsearch-result__meta"></div>
|
|
|
|
|
<ol class="mdx-iconsearch-result__list"></ol>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-12-16 19:08:57 +03:00
|
|
|
|
|
|
|
|
|
[Insiders]: ../insiders/index.md
|
|
|
|
|
[icon search]: icons-emojis.md#search
|
|
|
|
|
|
2022-08-21 20:10:19 +03:00
|
|
|
|
### Setting the page status
|
|
|
|
|
|
|
|
|
|
[:octicons-heart-fill-24:{ .mdx-heart } Sponsors only][Insiders]{ .mdx-insiders } ·
|
|
|
|
|
[:octicons-tag-24: insiders-4.22.0][Insiders] ·
|
|
|
|
|
:octicons-beaker-24: Experimental
|
|
|
|
|
|
|
|
|
|
A status can be assigned to each page, which is then displayed as part of the
|
|
|
|
|
navigation sidebar. First, associate a status identifier with a description by
|
|
|
|
|
adding the following to `mkdocs.yml`:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
extra:
|
|
|
|
|
status:
|
|
|
|
|
<identifier>: <description> # (1)!
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
1. The identifier can only include alphanumeric characters, as well as dashes
|
|
|
|
|
and underscores. For example, if you have a status `Recently added`, you can
|
|
|
|
|
set `new` as an identifier:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
extra:
|
|
|
|
|
status:
|
|
|
|
|
new: Recently added
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The page status can now be set for a document with the front matter `status`
|
|
|
|
|
property. For example, you can mark a page as `new` with the following lines at
|
|
|
|
|
the top of a Markdown file:
|
|
|
|
|
|
2022-09-11 20:25:40 +03:00
|
|
|
|
``` yaml
|
2022-08-21 20:10:19 +03:00
|
|
|
|
---
|
|
|
|
|
status: new
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# Document title
|
|
|
|
|
...
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The following status identifiers are currently supported:
|
|
|
|
|
|
|
|
|
|
- :material-alert-decagram: – `new`
|
|
|
|
|
- :material-trash-can: – `deprecated`
|
|
|
|
|
|
2021-12-16 19:08:57 +03:00
|
|
|
|
### 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:
|
|
|
|
|
|
2022-09-11 20:25:40 +03:00
|
|
|
|
``` yaml
|
2021-12-16 19:08:57 +03:00
|
|
|
|
---
|
|
|
|
|
template: custom.html
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# Document title
|
|
|
|
|
...
|
|
|
|
|
```
|
|
|
|
|
|
2022-07-17 16:20:08 +03:00
|
|
|
|
??? question "How to set a page template for an entire folder?"
|
|
|
|
|
|
|
|
|
|
With the help of the [built-in meta plugin], you can set a custom template
|
2022-09-11 20:25:40 +03:00
|
|
|
|
for an entire section and all nested pages, by creating a `.meta.yml` file
|
2022-07-17 16:20:08 +03:00
|
|
|
|
in the corresponding folder with the following content:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
template: custom.html
|
|
|
|
|
```
|
|
|
|
|
|
2021-12-16 19:08:57 +03:00
|
|
|
|
[theme extension]: ../customization.md#extending-the-theme
|
2022-07-17 16:20:08 +03:00
|
|
|
|
[built-in meta plugin]: #built-in-meta-plugin
|
2020-07-27 14:50:31 +03:00
|
|
|
|
|
2021-10-10 14:17:39 +03:00
|
|
|
|
## Customization
|
2021-09-04 16:58:26 +03:00
|
|
|
|
|
2021-10-10 14:17:39 +03:00
|
|
|
|
### Using metadata in templates
|
2020-09-20 12:24:46 +03:00
|
|
|
|
|
2021-05-01 20:04:44 +03:00
|
|
|
|
#### on all pages
|
|
|
|
|
|
|
|
|
|
In order to add custom `meta` tags to your document, you can [extend the theme
|
2021-10-10 22:04:22 +03:00
|
|
|
|
][theme extension] and [override the `extrahead` block][overriding blocks],
|
2021-10-10 14:17:39 +03:00
|
|
|
|
e.g. to add indexing policies for search engines via the `robots` property:
|
2020-07-27 15:44:47 +03:00
|
|
|
|
|
|
|
|
|
``` html
|
2021-09-12 11:15:21 +03:00
|
|
|
|
{% extends "base.html" %}
|
|
|
|
|
|
2020-07-27 15:44:47 +03:00
|
|
|
|
{% block extrahead %}
|
2020-08-10 13:50:37 +03:00
|
|
|
|
<meta property="robots" content="noindex, nofollow" />
|
2020-07-27 15:44:47 +03:00
|
|
|
|
{% endblock %}
|
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 22:04:22 +03:00
|
|
|
|
[overriding blocks]: ../customization.md#overriding-blocks
|
2021-05-01 20:04:44 +03:00
|
|
|
|
|
|
|
|
|
#### 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.:
|
|
|
|
|
|
|
|
|
|
``` html
|
2021-09-12 11:15:21 +03:00
|
|
|
|
{% extends "base.html" %}
|
|
|
|
|
|
2021-05-01 20:04:44 +03:00
|
|
|
|
{% 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 %}
|
|
|
|
|
```
|
|
|
|
|
|
2021-10-10 14:17:39 +03:00
|
|
|
|
You can now use `robots` exactly like [`title`][title] and
|
|
|
|
|
[`description`][description] to set values. Note that in this case, the
|
|
|
|
|
template defines an `else` branch, which would set a default if none was given.
|
|
|
|
|
|
|
|
|
|
[title]: #setting-the-page-title
|
|
|
|
|
[description]: #setting-the-page-description
|