Giter Site home page Giter Site logo

slarrauri / mkdocs-meta-descriptions-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from prcr/mkdocs-meta-descriptions-plugin

0.0 1.0 0.0 2.57 MB

๐Ÿ“‘ Generate meta descriptions from the first paragraphs in your MkDocs pages

Home Page: https://pypi.org/project/mkdocs-meta-descriptions-plugin/

License: MIT License

Python 100.00%

mkdocs-meta-descriptions-plugin's Introduction

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

Configuring the plugin

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

plugins:
  - meta-descriptions:
      export_csv: false
      verbose: 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 in your pages, especially if you're maintaining a big site.

verbose

If true, the plugin outputs a summary of how many pages have meta descriptions and other information while building your site. The default is false.

Alternatively, you can see the same information by running MkDocs with the --verbose flag.

See also

Read more about using MkDocs plugins.

mkdocs-meta-descriptions-plugin's People

Contributors

dependabot[bot] avatar prcr avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.