Extension:MetaDescriptionTag

An extension which gives users the ability to inject a &lt;meta&gt; description into the document header.

Note: Jim R. Wilson's excellent article Doing more with MediaWiki parser extensions contains a lengthy discussion of how this extension works.

Installation

 * 1) Create a file named MetaDescriptionTag.php containing the code below.
 * 2) Copy this file to $IP/extensions.
 * Note: $IP is your MediaWiki install directory.
 * 1) Enable the extension by adding this line to your LocalSettings.php:

Usage
Once installed, editors of your wiki can add a &lt;meta&gt; description tag by adding the following to the article text: &lt;metadesc&gt; PageDescription &lt;/metadesc&gt; Where PageDescription would be replaced by the desired meta description.

For example, the above would become: &lt;meta name="description" content="PageDescription" /&gt;

Example using template, variable substitution
(This approach requires MediaWiki 1.12 - or install Extension:TagParser. Explanation at Manual:Tag_extensions.)

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



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

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