Generate meta descriptions from the first paragraphs in your MkDocs pages
Project description
mkdocs-meta-descriptions-plugin
Use this MkDocs plugin to automatically generate meta descriptions for your pages using the first paragraph of each page. This is useful if you start each page with a short introduction or summary that can be reused as the meta description.
For each page, the plugin:
-
Checks that the page doesn't already have a meta description.
The plugin doesn't change any meta descriptions defined explicitly on the page meta-data.
-
Tries to find the first paragraph above any
<h2>to<h6>headings.The plugin only searches for the first paragraph until the start of the first section to ensure that the content is from the "introductory" part of the page.
-
Sets the meta description of the page to the plain text context of the paragraph, stripped of HTML tags.
If the page doesn't have a meta description defined manually by you nor automatically by the plugin, MkDocs sets the meta description of the page to the value of your site_description as a fallback.
Setting up and using the plugin
⚠️ Important: to use this plugin, you must either customize your existing theme to include the value of
page.meta.descriptionin the HTML element<meta name="description" content="...">, or use an MkDocs theme that already does this by default. I recommend using the excellent Material theme.
To set up and use the plugin:
-
Install the plugin using pip:
pip install mkdocs-meta-descriptions-plugin
Depending on your project, you may also need to add the plugin as a dependency on your
requirements.txtfile. -
Activate the plugin in your
mkdocs.yml:plugins: - search - meta-descriptions
Note: If you have no
pluginsentry in yourmkdocs.ymlfile yet, you'll likely also want to add thesearchplugin. MkDocs enables it by default if there is nopluginsentry set, but now you have to enable it explicitly. -
Activate the Meta-Data extension in your
mkdocs.yml:markdown_extensions: - meta
Read more about using MkDocs plugins.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs-meta-descriptions-plugin-0.0.4.tar.gz.
File metadata
- Download URL: mkdocs-meta-descriptions-plugin-0.0.4.tar.gz
- Upload date:
- Size: 135.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
572cc89554dddc0ac1ffff660d54c3f7681cfea3cc40e61eb5ae213ae128777f
|
|
| MD5 |
73041265788746442350e8cb63b59867
|
|
| BLAKE2b-256 |
336a2df1bce550700abd508a1b8dcfe9bc5460c352314c1a0cfebe1bbd325242
|
File details
Details for the file mkdocs_meta_descriptions_plugin-0.0.4-py3-none-any.whl.
File metadata
- Download URL: mkdocs_meta_descriptions_plugin-0.0.4-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24e1df727962fe8954e370aa5a91c1a2aa932aad328dadfb6549694187bb520b
|
|
| MD5 |
a917035c091434f4a2eb13d55987817a
|
|
| BLAKE2b-256 |
0871edde82ec6955f5ef56fda5b56416f8910092d2392d88f9e2b4c626ea8e54
|