How do I set the <head>'s <title> tag in MVC component's code? I know the page title (which would appear on top of the page) can be set in several ways but the <title> seems to be only settable from menu item properties. I need to set <title> without using menu items (from component code).


1 Answer 1


You can use Joomla's setTitle() method, like so:

use Joomla\CMS\Factory;

Factory::getDocument()->setTitle('My Custom Title');
  • It seems to set the tile on the site but not the <title> tag contents in the <head> section of the page.
    – ed22
    Commented May 6, 2020 at 12:08
  • @ed22 - Working perfectly fine for me. The browser sets the page title based on the <title> value, so I'm not sure how the tab shows the title but the <title> isn't updating.
    – Lodder
    Commented May 6, 2020 at 13:00

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.