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).


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
    May 6 '20 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
    May 6 '20 at 13:00

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.