<title><?= Html::encode($this->title) ?></title>
is rendered as
<title>My Yii Application</title>
I want to change the title “My Yii Application” to a custom one. How to set custom page titles that apply to all pages in every controller.
<title><?= Html::encode($this->title) ?></title>
is rendered as
<title>My Yii Application</title>
I want to change the title “My Yii Application” to a custom one. How to set custom page titles that apply to all pages in every controller.
In your controller create a param $title and put the title you want.
In the layout you can access to this param:
<title><?= Html::encode($this->content->title) ?></title>
Only be sure all the controllers have the param title.
My Yii Application
is mentioned in framework class? any idea
If it is a new Yii 2 installation, open your \views\site\index.php. There you will see the title definition as
$this->title
and overwrite it as needed.
Set the “name” in config/web.php
$config = [
'id' => 'basic',
'name' => "My Customized Website Name",
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'aliases' => [
I know this question was asked ages ago but I think a lot of people still struggle to figure this out. So putting in a more comprehensive answer below:
There are two parts to this:
$config = [
'id' => 'basic',
'name' => "My App Name",
$this->title = 'My App Name';