Extension:Description2

Category:Extensions without an imageCategory:GPL licensed extensions
MediaWiki extensions manual
Description2
Release status: stableCategory:Stable extensions
Implementation Data extractionCategory:Data extraction extensions, Parser extension Category:Parser extensions
Description Provides a meta description tag and adds data to parser output for other extensions to use.
Author(s) Daniel Friesen (Dantmantalk)
Latest version 0.4.1
Compatibility policy Master maintains backward compatibility.Category:Extensions with master compatibility policy
MediaWiki >= 1.38.0
Database changes No
License GNU General Public License 2.0 or later
Download Category:Extensions in Wikimedia version control
  • $wgDescriptionMaxChars
  • $wgDescriptionRemoveElements
  • $wgDescriptionAlgorithm
  • $wgEnableMetaDescriptionFunctions
Quarterly downloads 38 (Ranked 76th)
Translate the Description2 extension if it is available at translatewiki.net
Category:All extensions

The Description2 extension adds a description meta tag for articles automatically based on the content. This functionality appears to have been removed from MediaWiki at some point. There are some situations where description extraction (by entities less sophisticated than Google, like Facebook) will extract the wrong description information from the wiki and use something like the sitenotice as the description for a page instead of its content. This extension also adds the description to the parser output in a way that other extensions can make use of (to say provide description in a different format like Extension:OpenGraphMeta does, or perhaps to use it in article lists on the wiki).

Installation

  • Download and move the extracted Description2 folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Description2
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'Description2' );
    $wgEnableMetaDescriptionFunctions = true;
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Extra options

If you set $wgEnableMetaDescriptionFunctions = true; in your LocalSettings.php a {{#description2:}} parser function can be used to control the description outputted for the page and override it with a custom one. You can use these parser extensions like so:

{{#description2:This is a description}}

You can use the description2 parser function instead to provide a description tag you can control with a template's variables.

Algorithm

Description is extracted from the HTML representation of a page:

  1. Remove all <table> elements (and its contents).
  2. Find all <p> elements.
  3. Iterate over those paragraphs, stripping out all HTML tags (see strip_tags()) and trimming whitespace around it.
  4. The first non-empty paragraph (after all previous transformation) is picked as the description.

Things to consider:

  • When using templates at the top of the articles, if you use <div> instead of tables for the template, be sure it doesn't render paragraphs, which otherwise will be used as the description. This may happen if you have several <div> inside the template with newlines.

See also

Category:HTML head extensions Category:Search engine optimization extensions
Category:All extensions Category:Data extraction extensions Category:Extensions in Wikimedia version control Category:Extensions included in Canasta Category:Extensions included in Miraheze Category:Extensions included in WikiForge Category:Extensions included in wiki.gg Category:Extensions with master compatibility policy Category:Extensions without an image Category:GPL licensed extensions Category:HTML head extensions Category:OutputPageParserOutput extensions Category:ParserAfterTidy extensions Category:ParserFirstCallInit extensions Category:Parser extensions Category:Search engine optimization extensions Category:Stable extensions