You may know me as the founder, developer, and cheerleader for RichmondWiki, but when I’m not tinkering with MediaWiki my day job is a search engine optimization consultant. Simply put, this means that I work with companies to create strategies to increase traffic to their websites from Google (oh yeah, and the other engines too). With that mindset, I am always looking for ways to improve RichmondWiki’s visibility in search engines, and one of the biggest things that affects this is the links pointing to and from each page. Generally speaking, each link on the web is like a “vote” for a page’s popularity. The more votes a page has, the higher it can rank in search results (a grossly oversimplified explanation).
One of the problems with trying to optimize MediaWiki is that every article has some standard links across the top that allow users to take some sort of action. For example, you can edit an article, view its revision history, leave a comment, etc. It looks like this:

Each of these links on a page casts a “vote” for the destination page. For most of these links, the destination page is not something we want Google to find anyway, since revision history and edit pages can cause duplicate content problems. The easiest solution is simply to use the robots.txt file to block Google from indexing the directory where MediaWiki is installed (/w in our case) but it doesn’t completely solve the problem. I will write more on this in another post, but you can check out our robots file here.
To get the most SEO benefit from each article, we want to stop the leakage of votes from each article to its action pages. To do this, we’ll use the rel=”nofollow” attribute in our link structure. This tells search engines not to follow that link to the destination page or count it as a vote in their ranking algorithms.
rel=”nofollow” Structure
A typical link looks like this:
<a href=”http://www.example.com”>Example.com</a>
To block that link from being crawled by search engines, the nofollow attribute is added to the <a> like this:
<a href=”http://www.example.com” rel=”nofollow”>Example.com</a>
Simple, right?
Finding the Content Action Links in MediaWiki
It’s not as easy in MediaWiki, since the entire platform is built in PHP. That means there isn’t really any clean HTML to edit. It took a while, but I finally found the code that creates these Content Action links in my Monobook.php file (in the skins directory). RichmondWiki uses a slighly modified Monobook theme to accomodate the Google Adsense ads, but for this example we’ll assume it’s basic Monobook.
Look for the following code block within the p-cactions portlet <div>. The part that creates the href link is in bold:
<?php foreach($this->data['content_actions'] as $key => $tab) { ?>
<li id=”ca-<?php echo Sanitizer::escapeId($key) ?>”<?php
if($tab['class']) { ?> class=”<?php echo htmlspecialchars($tab['class']) ?>”<?php }
?>><a href=”<?php echo htmlspecialchars($tab['href']) ?>”<?php echo $skin->tooltipAndAccesskey(‘ca-’.$key) ?>><?php
echo htmlspecialchars($tab['text']) ?></a></li>
<?php } ?>
Now, somewhere above this code block you will want to declare a PHP string that we will add to the href. I called mine $seonofollow to keep it clear.
<?php $seonofollow = ‘ rel=”nofollow”‘; ?>
Next, print (echo) the string in the href structure by adding this to the p-cactions code block:
<?php echo $seonofollow; ?>
The proper place to add this is within the <a> chunk, so your final code block should look like this:
<?php $seonofollow = ‘ rel=”nofollow”‘; ?>
<li id=”ca-<?php echo Sanitizer::escapeId($key) ?>”<?php
if($tab['class']) { ?> class=”<?php echo htmlspecialchars($tab['class']) ?>”<?php }
?>><a href=”<?php echo htmlspecialchars($tab['href']) ?>”<?php echo $skin->tooltipAndAccesskey(‘ca-’.$key) ?><?php echo $seonofollow; ?>><?php
echo htmlspecialchars($tab['text']) ?></a></li>
The End Result
Once you upload the revised Monobook.php file to your MediaWiki skins folder, you should be able to load any article in your wiki and check the source code. If you did it correcly, you will end up with a set of Content Action links that look like this (click the image):
Keep an eye on your rankings in organic search results to see if this has an impact. If it does, you should receive more traffic to your wiki and hopefully more user contributions and edits! Good luck!
Extra Credit
The same rel=”nofollow” attribute can be added to the Personal URLs (login, preferences, etc) by calling the $seonofollow string in the p-personal portlet. Can you find out where to do that?
Possibly Related posts:
- More Prominent Edit Links Just logging in a couple subtle changes to the MediaWiki installation that......
- Request: MediaWiki Dofollow Extension RichmondWiki.org currently adds the rel=”nofollow” attribute to every external link (except the......
- Finally, an XML Sitemap Generator for MediaWiki My hero for the day is Jehy, the Russian programmer who created......
- New MediaWiki Editing Tools Coming Just in from CNET News, the Stanton Foundation has donated $890,000 to......




{ 7 trackbacks }
{ 1 comment… read it below or add one }
Thank you brother…