Extension:AdvancedMeta

This extension allows setting the robots, keywords and description meta tags for MediaWiki, for SEO purposes. Meta settings can be edited for individual pages, or entire namespaces can be denied from indexing by robots.

This is my first real plugin. Please do send me corrections or tips, or even update the code if you have better ideas.

Usage
Pages that are not excluded from indexing (see Installation) will have an extra section in their edit pages, as shown in the screenshot. These forms allow you to add meta keywords and a description, as well as setting the robots meta tag to index and/or follow your page. If the "index"-checkbox is disabled, keywords and descriptions are of no use obviously, but they will be saved in case you want to have the page indexed later.

Installation
To basically install the plugin, upload the source code below in a file called MWAdvancedMeta.php in the folder /extensions/ in your MediaWiki main folder. In LocalSettings.php add the lines If you want to let the MWAdvancedMeta class be included by means of autoloading, you probably know how and where to put the code.

There are some settings you can change in LocalSettings.php. Possible settings are namespaces that are indexed by default (default setting: NS_MAIN and NS_PROJECT), keywords that are added to every single page, and users/usergroups that are allowed to edit the meta settings.

To set these settings, store the MWAdvancedMeta instance return by the setup function, and call the setters:

Namespaces that are not in the 'indexedpages' variable will get a "noindex,follow" by default. There is currently no setting to also prevent them from being followed, but I might add that sooner or later depending on if it's being requested (feel free to contact me).

Last, a table should be added to the mediawiki database. The following SQL should take care of that:

Compatibility
I'm not sure how this extension works combined with other meta plugins, but I'm afraid the ones that also work with keywords and descriptions will collide.

Change log

 * Version 1.3.0 (by Bart van Heukelom)
 * Encapsulated the entire plugin in an object (PHP 5 only).


 * Version 1.2.1
 * Improved permission check for editing/updating meta info
 * Noindex redirect pages as well


 * Version 1.2.0
 * Added a hook to move meta data for a new article from a temporary place (article id 0) to it's new article id


 * Version 1.1.0:
 * Added a notification on the edit page which keywords are always used
 * Added the 'always used' keywords to pages with no user-defined keywords as well
 * Fixed edit conflict for pages that are not indexed
 * Added freeResults to the getMetaByArcticleID query


 * Version 1.0.0:
 * Set meta robots="noindex/follow" to entire namespaces
 * Set default meta keywords that are added to all indexed pages
 * Allow specific users or usergroups to edit meta information to indexed pages
 * Add/modify robots, keywords and descriptions for individual pages