Extension:CanonURL

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png

Release status: beta

CanonURL screenshot.jpg
Description Adds the canonical links to the head of Mediawiki pages according to Google Canonicalization Content Guidelines
Author(s) (Abhi M Balakrishnantalk)
Latest version 0.3 (24 March 2013)
MediaWiki 1.20
PHP 5.3
License GPL
Download Mirror 1
Mirror 2
Readme
Example Secpedia
Tags
seo, canonical, url
Hooks used
BeforePageDisplay

Translate the CanonURL extension if possible

Check usage and version matrix; code metrics

Adds the canonical links to the head of Mediawiki pages according to Google Canonicalization Content Guidelines to avoid duplicate content issues.

Introduction[edit | edit source]

Many of the Mediawiki installations out there uses Short URLs including Wikipedia. Almost all these installations makes the URLs short and easy to remember. However, this makes the content available in both long URLs and short URLs.

For Example:
Main Page of Wikipedia can be accessed from
http://en.wikipedia.org/wiki/Main_Page and
http://en.wikipedia.org/w/index.php?title=Main_Page

Even though a normal user is not going to get disturbed by this issue, it can create major problems in search engine rankings. [1]

There are two known methods to fix this issue:
1. Redirect long URLs to short URLs automatically[2] or
2. Specify your canonical.[3]

This extensions makes use of the second method, by specifying the canonical URL. In this method, content is still accessible through both the URLs, but the short URL is set as the canonical URL. Thus search engines will list short URLs only.

Wikipedia deals with this problem a third way by using robots.txt to disallow indexing of the long form url (aka http://en.wikipedia.org/w/index.php?title=Main_Page). Thus the search engine should only see the short version. However, Google does not recommend blocking crawler access to duplicate content on website, whether with a robots.txt file or other methods.[4]

Installation[edit | edit source]

  • Download and extract the files in a directory called CanonURL in your extensions/ folder. If you're a developer and this extension is in a Git repository, then instead you should clone the repository.
  • Add the following code at the bottom of your LocalSettings.php:
require_once( "$IP/extensions/CanonURL/CanonURL.php" );
  • Clear the cache of your browser
  • Check the HTML source and confirm the presence of following line before
    <link rel="canonical" href="CANONICAL_URL_OF_CURRENT_PAGE" />
  • Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.

References[edit | edit source]

  1. Canonicalization - Webmaster Tools Help
  2. Official Google Webmaster Central Blog: Reunifying duplicate content on your website
  3. Official Google Webmaster Central Blog: Specify your canonical
  4. Duplicate content - Webmaster Tools Help