Package: mkdocs-meta-descriptions-plugin
mkdocs-meta-descriptions-pluginUse 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 plugindoesn't changeany meta descriptions defined explicitly on thepage 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 yoursite_descriptionas a fallback.Setting up and using the plugin⚠️Important:to use this plugin, you must eithercustomize your existing themeto include the value ofpage.meta.descriptionin the HTML element<meta name="description" content="...">, or use anMkDocs themethat already does this by default. I recommend using the excellentMaterial theme.To set up and use the plugin:Install the plugin using pip:pipinstallmkdocs-meta-descriptions-pluginDepending on your project, you may also need to add the plugin as a dependency on yourrequirements.txtfile.Activate the plugin in yourmkdocs.yml:plugins:-search-meta-descriptionsNote:If you have nopluginsentry 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.Configuring the pluginUse the following options to configure the behavior of the plugin:plugins:-meta-descriptions:export_csv:falsequiet:falseenable_checks:falsemin_length:50max_length:160trim:falseexport_csvIftrue, the plugin exports the meta descriptions of all Markdown pages to the CSV file<site_dir>/meta-descriptions.csv. The default isfalse.This is useful to review and keep track of all the meta descriptions for your pages, especially if you're maintaining a big site.quietIftrue, the plugin logs messages of levelINFOusing the levelDEBUGinstead. The default isfalse.Enable this option to have a cleaner MkDocs console output. You can still see all logs by running MkDocs with the--verboseflag.enable_checksIftrue, 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 thanmin_lengthor longer thanmax_length. The default isfalse.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_lengthMinimum number of characters that each meta description should have. The default is 50 characters, based onthese general recommendations.Make sure that you setenable_checks: truefor this option to have an effect.max_lengthMaximum number of characters that each meta description should have. The default is 160 characters, based onthese general recommendations.Make sure that you setenable_checks: trueortrim: truefor this option to have an effect.trimIftrue, the plugin trims meta descriptions coming from the first paragraph of the pages to include at mostmax_lengthcharacters.Note that this option doesn't change any meta descriptions defined explicitly on thepage meta-data.See alsoRead more aboutusing MkDocs plugins.