Cakephp – Add meta tags to views

This is how you add well formated meta tags to a cakephp views even thou the meta tags are rendered in the layout.

In the head section of your layout, add this line:
<?php echo $scripts_for_layout ?>

And in the view template you can call the meta HTML helper function to dynamticly add tags and descriptions to pages.
$html->meta('keywords', 'keywords for the page goes here one two three', array('type' => 'keywords'), false);
$html->meta('description', 'The description of the page goes here, cakephp is cool', array('type' => 'description'), false);

Source: http://book.cakephp.org/view/206/Inserting-Well-Formatted-elements

No Comments.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>