From Supernifty
Jump to: navigation, search

Using MediaWiki as a CMS has some challenges, particularly when applying SEO techniques. This page describes workarounds for MediaWiki limitations.

META keywords and title

It's impossible in MediaWiki to:

  • add meta keywords
  • add a meta description
  • have a title different to the actual <H1> heading on the page.

An extension was written to address these deficiencies.


Search engines can mark sites down if they consider it to contain duplicate content. Update your robots.txt file to prevent this from happening with a MediaWiki installation.

Recommended MediaWiki robots.txt file:

User-agent: *
Disallow: /wiki/Special:Random
Disallow: /wiki/Special%3ARandom
Disallow: /wiki/Special:Search
Disallow: /wiki/Special%3ASearch

Public Editing

MediaWiki by default allows anyone to login and shows all kinds of extra links for the general public to edit the page. If you aren't allowing the general public to create accounts then you may want to clean this up.

Don't let just anyone edit your pages

  • Edit your LocalSettings.php file:
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['upload'] = false;

Don't show all the extra edit buttons and links

  • In skins/MonoBook.php, find the divs with id p-cactions and p-personal. These are the links along the top of the page.
  • Surround with the following:

<?php global $wgUser; if( $wgUser->isLoggedIn() ) { ?>

divs here...

<?php } ?>

  • To remove the edit links next to each heading, edit skins/MonoBook.php or whatever skin you are using.
  • Find the tag </head>
  • Insert the following code:

<?php global $wgUser; if( !$wgUser->isLoggedIn() ) { ?>
  <style type="text/css">.editsection { display: none; }</style>
<?php } ?>

nofollow tag

At some point MediaWiki decided to make the nofollow tag default for all external links.

The nofollow tag applied to a link means that it will be ignored by the search engines. And it's generally agreed that Google is very interested in incoming links.

If you allow anyone to edit your pages, then this theoretically discourages link spam.

But if you have links pointing outside your wiki, that you'd like the search engines to consider, then turn off nofollow.

Disabling nofollow in MediaWiki

  • Edit LocalSettings.php
  • Add the line $wgNoFollowLinks = false;

cache purging

When making these changes, the cache may prevent you seeing them.

To purge a page, append ?action=purge to it