Search code examples
cakephpcanonical-link

CakePHP Canonical Tag with html helper


How can I create this using the html helper? (with inline=false so i can specify it on a per-view basis)

<link rel="canonical" href="http://www.example.com/product.php?item=swedish-fish" />

Can't seem to find anything on this, apart from a patch that doesn't work.


Solution

  • Found this in CakePHP bugtracking site : http://cakephp.lighthouseapp.com/projects/42648/tickets/1063-support-for-custom-meta-tag-elements-in-htmlhelper

    Apparently you can use

    echo $this->Html->meta('canonical', 'http:://example.com', array('rel'=>'canonical', 'type'=>null, 'title'=>null));
    //outputs <link href="http:://example.com" rel="canonical" />