Skip to main content

mkdocs-meta-descriptions-plugin

CI/CD Codacy Codacy Badge PyPI

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.

Meta description obtained from first paragraph of the page

For each page, the plugin:

  1. 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.

  2. 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.

  3. 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.description in 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:

  1. 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.txt file.

  2. Activate the plugin in your mkdocs.yml:

    plugins:
      - search
      - meta-descriptions
    

    Note: If you didn't have a plugins declaration in your mkdocs.yml file before this step, you'll likely also want to add the search plugin. This is because MkDocs enables the search plugin by default when there is no plugins declaration, but now you have to enable it explicitly.

Configuring the plugin

Use the following options to configure the behavior of the plugin:

plugins:
  - meta-descriptions:
      export_csv: false
      quiet: false
      enable_checks: false
      min_length: 50
      max_length: 160
      trim: false
      fallback_if_short: false

export_csv

If true, the plugin exports the meta descriptions of all Markdown pages to the CSV file <site_dir>/meta-descriptions.csv. The default is false.

This is useful to review and keep track of all the meta descriptions for your pages, especially if you're maintaining a big site.

quiet

If true, the plugin logs messages of level INFO using the level DEBUG instead. The default is false.

Enable this option to have a cleaner MkDocs console output. You can still see all logs by running MkDocs with the --verbose flag.

enable_checks

If true, the plugin outputs a warning for each page that will have an empty or default meta description, as well as for each meta description shorter than min_length or longer than max_length. The default is false.

Enable this option if you want to make sure that all pages have a meta description and that each meta description follows general SEO best practices.

min_length

Minimum number of characters that each meta description should have. The default is 50 characters, based on these general recommendations.

Make sure that you set enable_checks: true for this option to have an effect.

max_length

Maximum number of characters that each meta description should have. The default is 160 characters, based on these general recommendations.

Make sure that you set enable_checks: true or trim: true for this option to have an effect.

trim

If true, the plugin trims meta descriptions coming from the first paragraph of the pages to include at most max_length characters. The default is false.

Note that this option doesn't change any meta descriptions defined explicitly on the page meta-data.

fallback_if_short

If true, the plugin uses the value of site_description as the meta description when the first paragraph is shorter than min_length. The default is false.

Note that this option doesn't change any meta descriptions defined explicitly on the page meta-data.

See also

Read more about using MkDocs plugins.

Metadata

Release files for mkdocs-meta-descriptions-plugin 4.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkdocs-meta-descriptions-plugin 4.1.0
File Size Uploaded
mkdocs_meta_descriptions_plugin-4.1.0.tar.gz 145.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-meta-descriptions-plugin 4.1.0
File Interpreter ABI Platform
mkdocs_meta_descriptions_plugin-4.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 153.9 kB

Release files / mkdocs_meta_descriptions_plugin-4.1.0.tar.gz

Download URL mkdocs_meta_descriptions_plugin-4.1.0.tar.gz
Size 145.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2da083f97ad4d580de3fcef9ea7d2c60037445addfb41d1272f5813659ddb765
BLAKE2b-256 checksum
How to use checksums
2b18ee307424dd767c14b3b90137180fb0bc4784148eb3b6985bcf7324ba3174
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 19, 2025.

Transparency log

Release files / mkdocs_meta_descriptions_plugin-4.1.0-py3-none-any.whl

Download URL mkdocs_meta_descriptions_plugin-4.1.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1fb07c1de09e58af82d7ef85bd462766bac916f91b3a3de9f569ca495e6b810
BLAKE2b-256 checksum
How to use checksums
9454da9ea958a070aac4bc1bed682f55aa090eff3130af5f59ad83014b2191b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 19, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

4.1.0 This release

2 release files

4.0.0

2 release files

3.0.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page