How to set custom title instead of My Yii Application Yii 2

<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

https://www.yiiframework.com/doc/guide/2.0/en/structure-applications#name

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:

  1. Changing the name of the application itself such that it shows correctly in the home page if you print out the application name. The place to fix this is in config/web.php
$config = [
	'id' => 'basic',
	'name' => "My App Name",
  1. However, the title of the home page will still show “My Yii Application”. To to change this, you need to change in the /views/site/index.php and change this:

$this->title = 'My App Name';