How I can change page header title from controller in admin page?

enter image description here

In the picture I want to change Dashboard to something else. I tried below code in execute method of the controller

$pageFactory = $this->resultPageFactory->create();
$pageFactory->getConfig()->getTitle()->prepend(__("Your Title"));

It is adding the title to the browsers tab but not changing the header title in the main page. How to change main page title?

Below is the html shown on inspecting in the browser.

<div class="page-header-hgroup col-l-8 col-m-6">
<div class="page-title-wrapper">
    <h1 class="page-title">Dashboard</h1>

I have also tried below code

 $this->_view->getLayout()->getBlock('page.main.title')->setPageTitle('Something else');

It says Error: Call to a member function setPageTitle() on bool.

3 Answers 3


its loading from below file


This is the place where you can change the title -
Please check this screenshot at line number 41, you can edit it from here.
enter image description here

And I have tested it also. After replace then save and just do hard refresh browser will show you this change. As shown in the below picture.
enter image description here

EDITED: As your code is custom module so this is the file location is


Test Items is the Heading here. enter image description here

   15          $resultPage = $this->resultPageFactory->create();
   16          $resultPage->setActiveMenu('Biren_Crudimage::test');
   17:         $resultPage->getConfig()->getTitle()->prepend(__('Test Items'));
   18          $resultPage->addBreadcrumb(__('Test'), __('Test'));
   19          $resultPage->addBreadcrumb(__('Items'), __('Items'));
  • I also tried this core file change for testing but it didn't work for me. It is changing title in the tab only not on the page.
    – amitshree
    Jun 19, 2021 at 17:04
  • I edited my solution and at the bottom side, I added the code that is for custom module. Jun 19, 2021 at 19:25

I was able to make it work using below code in the controller:

 $this->_view->getPage()->getConfig()->getTitle()->prepend(__("test title")); // Added this line

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.