I am trying to set a page title which is different to the <h1> heading for my contact page, but there is a bug which does not let you use XML on the contact form, so I have included it in the <head> tags.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <title>Contact Us - Test</title>
    <link rel="canonical" src="http://www.extenderstore.com.au/contact/" src_type="url"/>
    <referenceContainer name="content">
        <block class="Magento\Cms\Block\Block" name="contact-store-info" after="contactForm">
                <argument name="block_id" xsi:type="string">contact_us</argument>
    <referenceBlock name="catalog.compare.sidebar" remove="true"/>
    <referenceBlock name="wishlist_sidebar" remove="true" />

How can I have a page title of "Contact Us - Test" and an <h1> heading of "Contact Us"?

2 Answers 2


You can use below code for h1 tag

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

Open your contacts_index_index.xml file inside your layout folder and place this code above the body tag.

    <title>Contact Form</title>

If above code does not work for you then do following.

This is a function under vendor/magento/module-contact/Block/ContactForm.php

It contains the following code:

 * @return $this
protected function _prepareLayout()
    $this->pageConfig->getTitle()->set(__('Contact Form'));
    return parent::_prepareLayout();

Add to translation file {your_theme}/i18n/en_US.csv of Your theme string

"Contact Us","Contact Us - Test"

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.