I have tried to change the title of the Orders and Returns page with XML with the following code.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <title>Orders and Tracking - Test</title>
    <link rel="canonical" src="http://www.extenderstore.com.au/sales/guest/form/" src_type="url"/>
    <referenceBlock name="page.main.title">
        <action method="setPageTitle">
            <argument translate="true" name="title" xsi:type="string">Orders and Tracking</argument>

The canonical URL appears but the title does not. I have looked in vendor/magento/module-sales and I can't find an XML file which sets the title so I am assuming it is being done with a PHP function. I have done some further research and to override this I would need to make a module. How do I create this?

  • Please mention the path of the file.. Commented Oct 27, 2017 at 13:20
  • I am having trouble finding the path of the file. Perhaps we can work with the customer login page which has a similar problem. vendor/magento/module-customer/Block/Form/Login.php Commented Oct 27, 2017 at 21:24

2 Answers 2


To change the title, you need to override the execute() function in \vendor\magento\module-sales\Controller\Guest\Form.php.

To do this, you need to create a new module:




Give preference to it:


<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Sales\Controller\Guest\Form" type="{vendor}\{module}\Controller\Guest\Form"/>

Override the execute() function:


namespace {vendor}\{module}\Controller\Guest;

class Form extends Magento\Sales\Controller\Guest\Form
public function execute()
        if ($this->_objectManager->get(\Magento\Customer\Model\Session::class)->isLoggedIn()) {
            return $this->resultRedirectFactory->create()->setPath('customer/account/');
        $resultPage = $this->resultPageFactory->create();
        $resultPage->getConfig()->getTitle()->set(__('New Orders and Returns Title'));
        return $resultPage;

run these 4 CLI commands afterwards in the exact same order to see the changes:

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento setup:static-content:deploy

php bin/magento cache:flush

I haven't tested it, but it should work.


@Lez, the module process above is very involved. It is like using a hammer to kill an ant.

If you have access to the theme file, you can also use the language file and redefined "Orders and Returns" to "WHAT EVER YOU WANT".

In the app/design/frontend/{Vendor}/{theme}/i18n/ folder find the file en_US.csv

if the folder /i18n/ is not there create one and add the the file en_US.csv (for English language definition)

Add the line "Orders and Returns","WHAT EVER YOU WANT"

Run the following commands and you are done.

 php bin/magento setup:static-content:deploy

 php bin/magento cache:flush

Make sure you clear any other cache system or browser.

Hope this helps.

Your Answer

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

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