Home > Magento > The Missing Title Tags

The Missing Title Tags

Posted on: 18th Mar 2010 By: Adam Moss No Comments

Magento’s dynamic menu which is produced to allow navigation through the categories has a major flaw which could be so easily addressed, and it effects the overall SEO of the site. If Magento wants to continue to claim to be the best optimised shopping cart out there, it needs to make sure all areas are covered. This simple hack will add the all important title tags to your category menu.

Open the following file:

app > code > core > Mage > Catalog > Block > Navigation.php

The code that we need to edit resides in two places and is identical in both cases. At about line 186 and 254 there’s a line of code that looks like this:

$html.= '<a href="'.$this->getCategoryUrl($category).'"><span>'.$this->htmlEscape($category->getName()).'</span></a>'."\n";

You can see that it is simply a link inside a list item (if you look at the surrounding code), so let’s add our title tag in and use the Category Name as the title text:

title="'.$this->htmlEscape($category->getName()).'"

Added into the code you should end up with something that looks like this:

$html.= '<a href="'.$this->getCategoryUrl($category).'" title="'.$this->htmlEscape($category->getName()).'"><span>'.$this->htmlEscape($category->getName()).'</span></a>'."\n";

You may need to refresh your cache before seeing the changes take place, but this is really all there is to it. Come on Varien, let’s have it there by default in 1.4.0.2!

Post A Comment

Your comments:
Enclose code snippets within the appropriate tags: [php][/php]   [js][/js]   [xml][/xml]   [css][/css]   [html][/html]
E.g: [php]<?php echo "hello world"; ?>[/php]

Search Blog

Archives

For the record...

Views & opinions in this blog are those of the individual and do not necessarily reflect those of E-commerce Web Design or the Creare Group.