I have been scouring the forums for the right way of changing the page title for a specific page or layout in Magento 2 but many answers rely on action methods which are now deprecated.
Essentially, I have set the store up so the suffix for each page title is "- CompanyName" but I would like to know how to create an exception for this for the home page (and other specific landing pages). I have changed the page title in a custom layout file successfully but the suffix is still appended to the end. Is there a sensible way of stopping this from happening on a specific page, like the home page?
Thank you.
Best Answer
You need to overwrite Magento\Framework\View\Page\Title::addConfigValues function.
etc/module.xml
di.xml
YourVendor/YourModule/Model/View/Page/Title.php
Replace YourVendor_YourModule with your own vendor and module names.