3

I'd like to set the title and add some scripts in the default Magento Contact page . So in my theme's directory I have added the following file:

Magento_Contact/layout/contact_index_index.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="cms_page_layout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <title>Contact1</title>
        <script src="https://....."/>
    </head>
</page>

which is not working. Am I missing something here?

--------------------------------UPDATE-------------------------------------

It seems that many pages have the same issue in my website. Many product pages (not all of them) and some other pages have head title "Create New Customer Account". I have no idea where this comes from and why it affects these pages like that. Any method tested in order to set the head title in these page fails.

1

Create the file contact_index_index.xml in theme folder app/design/frontend/Vendor/theme/Magento_Contact/layout

<?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">
    <head>
        <title>Your title</title>
        <script src="https://...." src_type="url"/>
    </head>
</page>
  • As writen in this question above, what you describe is what I have done, but it's not working – zekia Sep 24 '18 at 8:23
  • I have tested it with my test installation and its properly working and changing title have you cleared cache after making this change. Is your server is in production mode? – Aman Alam Sep 24 '18 at 8:35
  • Yes i have tried upgrade, cache:flush, cache:clean. Website is in developer mode. – zekia Sep 24 '18 at 8:43
  • Check i am there should be another module that is overriding theme – Aman Alam Sep 24 '18 at 8:49
1

you can try this :

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
layout="1column"xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
  <head>
      <title>Contact1</title>
      <css src="css/local-l.css"/>
  </head>
</page>

Run php bin/magento setup:upgrade.
  • I have tried this code, I have tried php bin/magento setup:upgrade, clearing cache etc. It's not working. – zekia Sep 24 '18 at 8:25
0

For Title try this:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="cms_page_layout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>

        <script src="https://....."/>
    </head>
    <body> 
        <referenceBlock name="page.main.title">
            <action method="setPageTitle">
                <argument translate="true" name="title" xsi:type="string">Add Your Title</argument>
            </action>
        </referenceBlock>
    </body> 

</page>
  • This changes the title in body. What I want is to change the <title> tag in <head>. – zekia Sep 24 '18 at 8:24
0

The answer to this is some kind of bug with meta title. It seems that head title gets it value from page/product Meta Title. If Meta Title is empty, page/product gets head title as "Create New Customer Account".

I filled all Meta Titles in order to view correct titles in my pages, but I don't know where this bug comes from.

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.