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).
-
Looks like a duplicate of joomla.stackexchange.com/search?q=setTitle+is%3Aquestion. If not please clarify.– mickmackusaCommented May 6, 2020 at 21:16
Add a comment
|
1 Answer
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.– ed22Commented 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.– LodderCommented May 6, 2020 at 13:00