2020-03-09 21:03:48 +03:00
|
|
|
---
|
2020-03-26 13:19:20 +03:00
|
|
|
template: overrides/main.html
|
2020-03-09 21:03:48 +03:00
|
|
|
hero: Set heroes with metadata
|
2017-03-11 18:15:23 +03:00
|
|
|
path: tree/master/docs/extensions
|
|
|
|
source: metadata.md
|
2020-03-09 21:03:48 +03:00
|
|
|
---
|
2017-03-11 18:15:23 +03:00
|
|
|
|
|
|
|
# Metadata
|
|
|
|
|
2020-03-10 01:12:10 +03:00
|
|
|
[Metadata][1] is an extension included in the standard Markdown library that
|
|
|
|
makes it possible to control certain properties in a page-specific context,
|
|
|
|
e.g. the page title or description.
|
2017-03-11 18:15:23 +03:00
|
|
|
|
2018-02-22 21:26:35 +03:00
|
|
|
[1]: https://python-markdown.github.io/extensions/meta_data/
|
2017-03-11 18:15:23 +03:00
|
|
|
|
2020-03-09 21:03:48 +03:00
|
|
|
## Configuration
|
2017-03-11 18:15:23 +03:00
|
|
|
|
2020-03-09 21:03:48 +03:00
|
|
|
Add the following lines to `mkdocs.yml`:
|
2017-03-11 18:15:23 +03:00
|
|
|
|
|
|
|
``` yaml
|
|
|
|
markdown_extensions:
|
2017-03-11 19:24:03 +03:00
|
|
|
- meta
|
2017-03-11 18:15:23 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Metadata is written as a series of key-value pairs at the beginning of the
|
|
|
|
Markdown document, delimited by a blank line which ends the metadata context.
|
|
|
|
Naturally, the metadata is stripped from the document before rendering the
|
|
|
|
actual page content and made available to the theme.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
``` markdown
|
2020-03-09 21:03:48 +03:00
|
|
|
---
|
2017-03-11 18:15:23 +03:00
|
|
|
title: Lorem ipsum dolor sit amet
|
|
|
|
description: Nullam urna elit, malesuada eget finibus ut, ac tortor.
|
2017-03-11 20:36:34 +03:00
|
|
|
path: path/to/file
|
2017-03-11 18:15:23 +03:00
|
|
|
source: file.js
|
2020-03-09 21:03:48 +03:00
|
|
|
---
|
2017-03-11 18:15:23 +03:00
|
|
|
|
|
|
|
# Headline
|
|
|
|
|
|
|
|
...
|
|
|
|
```
|
|
|
|
|
2020-03-20 18:47:47 +03:00
|
|
|
See the next section which covers the supported metadata.
|
2017-03-11 18:15:23 +03:00
|
|
|
|
2020-03-09 21:03:48 +03:00
|
|
|
### Setting a hero
|
2017-11-22 02:13:56 +03:00
|
|
|
|
2020-03-20 18:47:47 +03:00
|
|
|
Material for MkDocs exposes a simple text-only page-local hero via Metadata, as
|
|
|
|
you can see on the current page when you scroll to the top. It's as simple as:
|
2017-11-22 02:13:56 +03:00
|
|
|
|
|
|
|
``` markdown
|
2020-03-09 21:03:48 +03:00
|
|
|
hero: Set heroes with metadata
|
2017-11-22 02:13:56 +03:00
|
|
|
```
|
|
|
|
|
2018-02-11 21:18:33 +03:00
|
|
|
### Linking sources
|
|
|
|
|
2020-02-24 20:07:50 +03:00
|
|
|
When a document is related to a specific source file and the `repo_url` is
|
|
|
|
defined inside the project's `mkdocs.yml`, the file can be linked using the
|
2018-02-11 21:18:33 +03:00
|
|
|
`source` key:
|
|
|
|
|
|
|
|
``` markdown
|
|
|
|
source: file.js
|
|
|
|
```
|
|
|
|
|
2020-03-09 21:03:48 +03:00
|
|
|
The filename is appended to the `repo_url` set in `mkdocs.yml`, but can be
|
|
|
|
prefixed with a `path` to ensure correct path resolving. The name of the source
|
|
|
|
file is shown in the tooltip.
|
2018-02-11 21:18:33 +03:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
``` markdown
|
|
|
|
path: tree/master/docs/extensions
|
|
|
|
source: metadata.md
|
|
|
|
```
|
|
|
|
|
2018-12-28 17:11:54 +03:00
|
|
|
### Redirecting to another page
|
|
|
|
|
|
|
|
It's sometimes necessary to move documents around in the navigation tree and
|
2020-03-20 18:47:47 +03:00
|
|
|
redirect users from the old URL to the new one. The `redirect` meta-tag allows
|
2018-12-28 17:11:54 +03:00
|
|
|
to create a redirection from the current document to the address specified in
|
|
|
|
the tag.
|
|
|
|
|
|
|
|
For instance, if your document contains:
|
|
|
|
|
|
|
|
``` markdown
|
|
|
|
redirect: /new/url
|
|
|
|
```
|
|
|
|
|
|
|
|
accessing that document's URL will automatically redirect to `/new/url`.
|
|
|
|
|
2018-02-11 21:18:33 +03:00
|
|
|
### Overrides
|
|
|
|
|
|
|
|
#### Page title
|
2017-03-11 18:15:23 +03:00
|
|
|
|
2020-03-09 21:03:48 +03:00
|
|
|
The page title can be overridden on a per-document basis:
|
2017-03-11 18:15:23 +03:00
|
|
|
|
|
|
|
``` markdown
|
|
|
|
title: Lorem ipsum dolor sit amet
|
|
|
|
```
|
|
|
|
|
|
|
|
This will set the `title` tag inside the document `head` for the current page
|
2017-03-11 20:36:34 +03:00
|
|
|
to the provided value. It will also override the default behavior of Material
|
2017-03-11 18:15:23 +03:00
|
|
|
for MkDocs which appends the site title using a dash as a separator to the page
|
|
|
|
title.
|
|
|
|
|
2018-02-11 21:18:33 +03:00
|
|
|
#### Page description
|
2017-03-11 18:15:23 +03:00
|
|
|
|
2020-03-09 21:03:48 +03:00
|
|
|
The page description can also be overridden on a per-document basis:
|
2017-03-11 18:15:23 +03:00
|
|
|
|
|
|
|
``` yaml
|
|
|
|
description: Nullam urna elit, malesuada eget finibus ut, ac tortor.
|
|
|
|
```
|
|
|
|
|
|
|
|
This will set the `meta` tag containing the site description inside the
|
|
|
|
document `head` for the current page to the provided value.
|
|
|
|
|
2018-02-11 21:18:33 +03:00
|
|
|
#### Disqus
|
2017-03-11 18:15:23 +03:00
|
|
|
|
2020-03-09 21:03:48 +03:00
|
|
|
As described in the [getting started guide][3], Disqus can be enabled on a
|
|
|
|
per-document basis:
|
2017-03-11 18:15:23 +03:00
|
|
|
|
|
|
|
``` markdown
|
2018-02-11 21:18:33 +03:00
|
|
|
disqus: your-shortname
|
2017-03-11 18:15:23 +03:00
|
|
|
```
|
|
|
|
|
2020-03-09 21:03:48 +03:00
|
|
|
Disqus can also be disabled for a specific page by setting it to an empty value:
|
2017-03-11 18:15:23 +03:00
|
|
|
|
|
|
|
``` markdown
|
2020-06-07 12:56:06 +03:00
|
|
|
disqus: ''
|
2017-03-11 18:15:23 +03:00
|
|
|
```
|
|
|
|
|
2018-02-11 21:18:33 +03:00
|
|
|
[3]: ../getting-started.md#disqus
|