Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
mkdocs-meta-descriptions-plugin
Advanced tools
Generate meta descriptions from the first paragraphs in your MkDocs pages
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.
⚠️ 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:
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.
Activate the plugin in your mkdocs.yml
:
plugins:
- search
- meta-descriptions
Note: If you have no
plugins
entry in yourmkdocs.yml
file yet, you'll likely also want to add thesearch
plugin. MkDocs enables it by default if there is noplugins
entry set, but now you have to enable it explicitly.
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
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.
Note that this option doesn't change any meta descriptions defined explicitly on the page meta-data.
Read more about using MkDocs plugins.
FAQs
Generate meta descriptions from the first paragraphs in your MkDocs pages
We found that mkdocs-meta-descriptions-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.