Customize title

Hi all,

How to customize the tag <title> in Yii2 as before in Yii1

   // Custom <title> Yii1

   $this->pageTitle = "my custom title";

Try in Yii2

class SiteController extends Controller


   public $title;

   public function actionAbout()


       $this->title=Yii::$app->name . " - My Custom title";

       return $this->render('about');




<!DOCTYPE html>

<html lang="<?php echo Yii::$app->language;?>">

<title><?php echo Html::encode($this->title);?></title>





But not working.


$title is the view property now so in controller use $this->getView()->title.


Also in view


   // FILE: \_Local\server\root\yii2\views\site\about.php

   $this->title = 'About Us';

   // Here content VIEW




[size=“3”]Problem resolved![/size] :D