cakephp:如何使每个页面的标题和元数据唯一?

cakephp: how to make title and metas unique to each page?

我有一个用 cakephp 2.2 制作的项目

它使用 default.ctp 布局,其中

<title>, <meta> are harde coded 

所以我网站的每个页面 具有相同的标题和元数据

我的目标(对于 SEO)是使每个页面的标题和元数据独一无二(每个控制器)

实现该目标的最佳方法是什么?

使用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