7

I want to modify page title of customer login.
What is the simple way to modify page title?

/**
 * @return $this
 */
protected function _prepareLayout()
{
    $this->pageConfig->getTitle()->set(__('Customer Login'));
    return parent::_prepareLayout();
}
23

You can set title using below code:

<referenceBlock name="page.main.title">
    <action method="setPageTitle">
        <argument translate="true" name="title" xsi:type="string">My Dashboard</argument>
    </action>
</referenceBlock>

If you want to change customer login create a file name with customer_account_login.xml add below code:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>

            <!-- and for the page title: -->
            <referenceBlock name="page.main.title">
               <action method="setPageTitle">
                  <argument translate="true" name="title" xsi:type="string">Recipe</argument>
               </action>
            </referenceBlock>

    </body>
</page>
2

Put this function in Block page of that Module

public function _prepareLayout()  
{  

   $this->pageConfig->getTitle()->set(__('Your Page Title'));  

   return parent::_prepareLayout();  
}    
0

Also, check if your page title is being set by multiple modules. Depending on what you have installed, and the sequence, the page title can wind up being reset by something else after trying to set it.

I ran into a case where the page title was being set 4 times, and had to find the last one in the sequence and write a plugin to override that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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