Category Meta Title – Default Meta Titles for Category Pages

categorymeta-title

How do I create a default category meta title for all the category pages?

I would like it to be something like this:

<title>{{category name}} - blah blah blah blah</title>

I want it to be the default only for category pages.

Is this possible?

Best Answer

Add the following code in your head.phtml

if (Mage::registry(current_category)) {
    echo '<title> Categoryname- keyword1 keyword2 keyword3"';
}

EDIT

As far as I know Mage::registry('current_category') can be used to check whether we are in a category. See Alanstorm's Answer. The important parts of that answer is adding below for reference

Current versions of Magento register certain global variables (not PHP globals, but things global to the Magento system) on certain pages.

Calling the following

   $category = Mage::registry('current_category');         
   $product  = Mage::registry('current_product');
   $product  = Mage::registry('product');

will either return null if the objects haven't been set (i.e. you're on a page without a category or a product), or return category and product objects.

If a product object is returned you're on a product page.

If no product object is returned but a category object is, you're on a category page.

then you can print what you want.