Tuesday, 18 October 2016

yii2 - How to use registerMetatag in Yii 2

To define some meta tag through the registerMetaTag method, use the following code in your controller:


public function actionIndex()
{
    \Yii::$app->view->registerMetaTag([
        'name' => 'description',
        'content' => 'Description of the page...'
    ]);
    return $this->render('index');
}
and this markup in the layout:
<head>
    <?php $this->head() ?>
</head>
yii2 - How to use registerMetatag in Yii 2

No comments:

Post a Comment