Change any page title in Magento

Change any page title in Magento

Here’s a quicky one 🙂 How do you change page title of every Magento page if some titles are hardcoded into controller?

Since some controllers in Magento likes to force page titles like

$this->loadLayout();
...
$this->getLayout()->getBlock('head')->setTitle($this->__('My Account'));
$this->renderLayout();

we can’t go with setTitle through layout, since controller is setting title right before rendering.

There is a simple solution for this, use another variable for title display 🙂

In page/html/head.phtml template replace default

 

with

 

or if you don’t wish to use title prefix/sufix added from Magento admin, simply with

 

and now just set “forced” title for pages through layout files

 

Example for My Account page in layout/customer.xml:
<customer_account>
<reference name=”head”>
<action method=”setForcedTitle”><title>Account Dashboard</title></action>
</reference>

</customer_account>

😉

You made it all the way down here so you must have enjoyed this post! You may also like:

Build your 2017 Magento SEO strategy with these tips Ivona Namjesnik
Ivona Namjesnik

Build your 2017 Magento SEO strategy with these tips

Free eCommerce SEO consultations by Inchoo at Meet Magento Poland Tea Pisac Benes
Tea Pisac Benes

Free eCommerce SEO consultations by Inchoo at Meet Magento Poland

In SERP title tags no longer control what’s shown Toni Anicic
Toni Anicic

In SERP title tags no longer control what’s shown

Tell us about your project

Drop us a line. We'd love to know more about your project.