Isengo
Isengo

Reputation: 2073

Using Meta Description in the right place CakePHP 3

I am trying to use meta tags and description in cakephp 3. It is working so far, but I am facing the problem that I can´t put it in the of my page, because my .ctp files are rendered in my default.ctp

So for example I have my menu, footer etc. in my default.ctp and my page for the faq is in the faq.ctp How can I push those

<?php
echo $this->Html->meta('description','enter any meta description here');
?>

metadescription in the head tag? Do I need a template language like smarty and use blocks?

Upvotes: 1

Views: 1459

Answers (2)

dav
dav

Reputation: 9267

add this in your ctp file (there is NO echo )

<?php $this->Html->meta('description', 'some text here', ['block' => true]);?>

and this line into your layout

<?php echo $this->fetch('meta');?>

see also similar question with title: $this->set('title', 'Title Name'); not working in CakePHP 3.x

Upvotes: 2

Salines
Salines

Reputation: 5767

In layout:

<?php
echo $this->Html->meta('description',$description);
?

in your faq.ctp or faq() method:

<?php
$this->set('description','enter any meta description here');
?

Upvotes: 2

Related Questions