Extension:Add HTML Meta and Title

From MediaWiki.org
Jump to: navigation, search
Language:Project:Language policy English  • русский
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
Add HTML Meta and Title

Release status:Extension status stable

ImplementationTemplate:Extension#type Tag
DescriptionTemplate:Extension#description Allows for easier SEO (search engine optimization) with MediaWiki.
Author(s)Template:Extension#username Vladimir Radulovski, Jim Wilson, Dennis Roczek (dennisroczektalk)
Latest versionTemplate:Extension#version 0.7 (2015-09-29)
MediaWikiTemplate:Extension#mediawiki 1.24+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license MIT License
Hooks usedTemplate:Extension#hook

Translate the Add HTML Meta and Title extension if it is available at translatewiki.net

Check usage and version matrix.

The Add HTML Meta and Title extension allows for easier SEO (search engine optimization) with MediaWiki. It is based in part on the extension MetaKeywordsTag.


When you enter the following in a wiki page:

<seo title="word1,word2" metakeywords="word3,word4" metadescription="word5,word6" google-site-verification="123456789-abfd123456" />

...or the shorter...

<seo title="word1,word2" metak="word3,word4" metad="word5,word6" google-site-verification="123456789-abfd123456" />

...these words are added to the HTML title and meta headers. This makes SEO (search engine optimization) with MediaWiki easier.

For example, the above would become:

<title>Original title, word1,word2</title>         (the string ", word1,word2,..." is added)
<meta name="word3,word4" content="word5,word6" />
<meta google-site-verification="123456789-abfd123456" />

(This is a new meta tag - existing metas are left untouched.)


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


  • added support for PHP CodeSniffer checks
  • fixed any remaining errors and warnings.
  • added Google's site verification tag
  • modified to work with MW versions 1.1.2 and up (Revision by Mic)
  • have put $emt=""; in the parseSEO function because I got some nasty PHP notice for an unitialised variable...
  • added htmlspecialchars() as a filter to the text that is displayed in the title and meta - anything else needed to prevent malicious people? I think no. (If you are an English speaker you may want to use the htmlentities PHP function, which is more restrictive)
  • Initital version - everything works.

See also[edit]

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