Reputation: 12054
I have a project made in cakephp 2.2
It uses default.ctp layout where
<title>, <meta> are harde coded
so EACH page of my site has same title and metas
My goal (for SEO) is to make title and meta unique for each page (each controller)
What is the best way to achieve that ?
Upvotes: 1
Views: 214
Reputation: 1793
Use Extending Views
<?php
// in your view file
$this->assign('title', 'best title');
$this->start('meta');
echo $this->Html->meta('keywords', 'enter any meta keyword here');
$this->end();
?>
// in your layout file (default.ctp)
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo $this->fetch('title'); ?></title>
<?php echo $this->fetch('meta'); ?>
</head>
// rest of the layout follows
Upvotes: 3