From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.svg

Release status:Extension status stable

ImplementationTemplate:Extension#type Tag
DescriptionTemplate:Extension#description Provides a tag for adding a custom <meta> description to the document's <head>
Author(s)Template:Extension#username Dror S.,

Joshua C. Lerner (original author)

Latest versionTemplate:Extension#version 0.4.0 (2017-05-22)
MediaWikiTemplate:Extension#mediawiki 1.25+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license MIT License
See below
Hooks usedTemplate:Extension#hook

Translate the MetaDescriptionTag extension if it is available at translatewiki.net

Check usage and version matrix.

The MetaDescriptionTag allows users to add a <meta> description into a page's <head>.

Warning Warning: Version 0.4.0 breaks compatibility with MediaWiki < 1.25. It should work with MediaWiki 1.25+ in theory, but was only tested with MediaWiki 1.27.


  • Download, extract and place the file(s) in a directory called MetaDescriptionTag in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'MetaDescriptionTag' );
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

To users running MediaWiki 1.24 or earlier:

The instructions above describe the new way of installing this extension using wfLoadExtension() If you need to install this extension on these earlier versions (MediaWiki 1.24 and earlier), instead of wfLoadExtension( 'MetaDescriptionTag' );, you need to use:

require_once "$IP/extensions/MetaDescriptionTag/MetaDescriptionTag.php";


Once installed, editors of your wiki can add a <meta> description tag by adding the following to the article text:


Where PageDescription would be replaced by the desired meta description.

For example, the above would become:

<meta name="description" content="PageDescription" />

Usage through a template[edit]

Say for example you want use a template to set the meta description to something like:

<metadesc>Extract from the article ARTICLETITLE</metadesc>

Create a template called (for example) "Template:Metadesc". Add the following content:

{{#tag:metadesc | Extract from the article {{{1}}} }}

In the article to which you set the meta description, add:

{{metadesc|{{PAGENAME}} }}



This is re-write to make it compatible with more modern MediaWiki practices and make sure it works nicely with MediaWiki 1.27+:

  • Extension Registration (extension.json)
  • json i18n files - An actual README file! :-)
  • Switching to semantic versioning.

Fix i18n to work with v1.16+, sanitize output using htmlspecialchars().


Change syntax to <metadesc>some content</metadesc> to support template variable substitution.


Initial release.

See also[edit]

Other languages:Project:Language policy English  • русский