How to set page title to have html on it E.G

$this->pageConfig->getTitle()->set(__('Your'.html_entity_decode(' <span>Page</span>'). 'Title')); 

That's ain't working! Anyone know how thanks in advance

  • It is your custom module? If not then can you please tell me the path where you are trying. file path – Ravi Soni Jul 3 at 9:29
  • @RaviSoni I've looked at .../vendor/magento/module-theme/view/frontend/templates/html/title.phtml and I can see that $block->escapeHtml($block->getPageHeading()) it won't work as it's escaping it so I just overwritten title.phtml in my custom html then remove the escapeHtml so I can add html to the title thanks – Juliano Vargas Jul 3 at 9:57

if you need a page title into the phtml file than just try this below block

echo $block->getLayout()->getBlock('page.main.title')->getPageTitle();

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.