Setting page titles and meta tags in cakephp 2.0

Today I needed to have page titles and meta tags correctly setup for each page in a website i had often used methods like placing variables and setting them to the template in the app controller in a beforeFilter. Then if i needed a different meta tag on another page like contact for example i could go to the contact controller and and overwrite these variables. A great idea but didn’t work too well for the simple pages and the pages controller.

Here is Idea how you can add page titles and meta tags easy in your cake pages

1- First we need to set the page tile,place this code within your method on the controller :
$this->set(“title_for_layout”,”your page title goes here”);

2- Second add below code to your respective view page :

echo $this->Html->meta(‘keywords’, ‘your keywords goes here’, array(‘type’ => ‘keywords’, ‘inline’ => false));
echo $this->Html->meta(‘description’, ‘your description goes here’, array(‘type’ => ‘description’, ‘inline’ => false));

Hope this will help!!!!!!!!!!

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *