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, create a folder called MWAdvancedMeta in /extensions/ in your MediaWiki main folder, then upload the source code below in two files called MWAdvancedMeta.php and MWAdvancedMeta.i18n.php in the new folder. In LocalSettings.php add this line

Add the page Mediawiki:Globalkeywords into your own wiki and write the global keywords there, splitted in commas.

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), and users/usergroups that are allowed to edit the meta settings (default: sysop and bureaucrat).

To set these settings, add this line first

Then add one or more of these lines


 * Warning: If you don't set these rules, by default all sysops and bureaucrats can modify meta information

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 (note: change 'mw' to your wiki prefix as needed for the AL code and modify the table name referenced in the "write" function as well....):

If you are upgrading it from 1.3.0 or older, run this SQL instead: since 'titlealias' is a new column for a new function.

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 2.0.1
 * Fixed robots policies for MediaWiki 1.16.0 and higher


 * Version 2.0.0 (by Zayoo)
 * Added internationalization (i18n) and added TitleAlias input box. Allow $1 for FULLPAGENAME
 * Function for TitleAlias. Recreate the HTML title with Mediawiki:Pagetitle.
 * Relocated some functions to better positions
 * Fixed a bug in usergroup names
 * Use Mediawiki:Globalkeywords instead of $globalKeywords so that sysops can change it conveniently and support UTF-8 charactors. $globalKeywords has been removed. Also still show the global keywords if no meta record for this article.
 * If the meta information is normal (index, follow, no titlealias, no keywords, no description), DELETE the record instead of INSERT or UPDATE to save space in database.


 * 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