How to set page title in Magento 2?

In Magento 2, We can set page title using Controller as well as Using XML. I have given example for set page title using Controller and XML Way.

Using Controller,

Using Controller, We can set title by just call lineĀ  $this->_view->getPage()->getConfig()->getTitle()->prepend(‘title name’)

Using XML,

Using XML you can set your page title by <title> tag in <head> section.