Joomla - Custom Page Title

on Sunday, 12 December 2010.

In the past I've used a joomla plugin called Title Manager. However I've noticed that it isn't as flexible as it should be.

So I've come up with some code that gives you the ability to name your front page title & append your desired description to all other titles. This is essential for SEO.

PHP

Insert this php code in your template's index.php file just before the closing </head> tag
hint: make sure it's inside: <?php ... ?>

$document = &JFactory::getDocument();

if (JURI::root() == JURI::current()) { // Front Page
  $document->setTitle( "Your Front Page Title" );
} else { // All other pages
  $document->setTitle( $document->getTitle() . " « Your Site Name" );
}

Example

For this site I changed the above code to:

$document = &JFactory::getDocument();

if (JURI::root() == JURI::current()) { // Front Page
  $document->setTitle("Paul Mason Web Development Blog");
} else { // All other pages
  $document->setTitle( $this->getTitle() . ' « Paul Mason' );
}

Finally to check that your site titles have been indexed by google type in the search box: "site:yoursite.com" i.e. in my case "site:paulmason.name". Note that this won't happen straight away.

Hope this was helpful!

blog comments powered by Disqus