Magento: How to add noindex, nofollow robots meta tag or change meta title or description on certain pages

Here’s a small tip on how to modify title, description or add meta robots tag on any magento page via xml layouts or layout updates.

It’s obvious how to do that for CMS or products page (on the Meta Data tab). There you can change Meta description or keywords. What about robots meta tag? or changing titles or description on checkout page? You would need to do in case:

  • you don’t want google to archive your products prices, therefore you would need to add noarchive to robots meta tag
  • you don’t want duplicate or unnecessary content in search engines, so you would use noindex, follow
  • you want to update checkout/contact/send a friend page meta description or title.

The approach is very simple…

For products, cms pages (something that’s being edited in admin panel) use layout updates. Just throw in code such as this:

<reference name="head">
   <action method="setRobots"><value>NOINDEX,FOLLOW</value></action>

You can add noarchive too. For any other type of pages you can use your local.xml (Reminder: local.xml resides in your theme/layout directory and has a purpose of misc local layout overrides) to do updates. Use the handle of the page, such as this (cart index in this case):

   <reference name="head">
<action method="setRobots"><value>NOINDEX,FOLLOW</value></action>
      <action method="setTitle"><value>Magento Ecommerce Title</value></action>
      <action method="setDescription"><value>Ecommerce by doejo. proceed to checkout</value></action>

Note: A lot of the .xml layouts already have a name handle. You just need to modify those, if you need to. 

Filed in: Web Development