yarek
yarek

Reputation: 12054

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

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

Answers (1)

Sony
Sony

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

Related Questions