Skip to main content

Generate meta descriptions from the first paragraphs in your MkDocs pages

Project description

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 have no plugins entry in your mkdocs.yml file yet, you'll likely also want to add the search plugin. MkDocs enables it by default if there is no plugins entry set, but now you have to enable it explicitly.

  3. Activate the Meta-Data extension in your mkdocs.yml:

    markdown_extensions:
      - meta
    

Read more about using MkDocs plugins.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs-meta-descriptions-plugin-0.0.4.tar.gz (135.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Hashes for mkdocs-meta-descriptions-plugin-0.0.4.tar.gz
Algorithm Hash digest
SHA256 572cc89554dddc0ac1ffff660d54c3f7681cfea3cc40e61eb5ae213ae128777f
MD5 73041265788746442350e8cb63b59867
BLAKE2b-256 336a2df1bce550700abd508a1b8dcfe9bc5460c352314c1a0cfebe1bbd325242

See more details on using hashes here.

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

Hashes for mkdocs_meta_descriptions_plugin-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 24e1df727962fe8954e370aa5a91c1a2aa932aad328dadfb6549694187bb520b
MD5 a917035c091434f4a2eb13d55987817a
BLAKE2b-256 0871edde82ec6955f5ef56fda5b56416f8910092d2392d88f9e2b4c626ea8e54

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page