I had the pleasure of talking to Phil Braddock, a Melbourne based Joomla developer, over the Christmas holidays.
He runs Salsa Internet and is someone who comes at Joomla from the perspective of someone focused on trying to improve Joomla’s SEO performance. There seems to be an increasing number of us! As the number of people wanting to use Joomla increases, a lot of people are working out how to improve its less SEO-friendly aspects.
One of those is inability to create a unique meta title that might be different from what actually appears on the page. To give an example from Phil’s site, his portfolio page is simple has the words "Portfolio > Websites" on the top of the content item. That makes sense to a reader, but is next to useless if it was also the meta title. Look up to the browser bar however, and you’ll see the page’s actual meta title is: "Joomla Web Design and Client Website Portfolio of our work, Melbourne, Australia". Stuffed with valuable keywords!
How did he do this? In Joomla content items you have the "Title" and the "Title Alias". Often people don’t utilize the alias field, but with a little hacking you can add your super-duper meta title in the "Title Alias" field and still have your nice simple title on the page.
What do you need to do? Follow these five simple instructions:
1. OPEN components/com_content/content.php
2. LOOK FOR:
// page title
$mainframe->setPageTitle( $row->title );
3. CHANGE TO:
// If title alias < 20 characters, page title will be: Site name – title
// else page title will be: Title alias
if (strlen($row->title_alias) < 20 )
{
$mainframe->setPageTitle( $row->title );
}else{
$mainframe->setPageTitleAlias( $row->title_alias );
}
// END CODE SNIPPET
** NOTE: THIS MUST BE DONE IN 2 PLACES IN THE CONTENT.PHP FILE
4. OPEN includes/joomla.php file and look for:
function setPageTitle( $title=null ) {
if (@$GLOBALS[‘mosConfig_pagetitles’]) {
$title = trim( htmlspecialchars( $title ) );
$title = stripslashes($title);
$this->_head[‘title’] = $title ? $GLOBALS[‘mosConfig_sitename’] . ‘ – ‘. $title : $GLOBALS[‘mosConfig_sitename’];
}
}
5. Add the following function AFTER this (note: do not replace the setPageTitle function):
// setPageTitleAlias – title of the content page to use tile_alias instead
/**
* @param string
*/
function setPageTitleAlias( $title_alias=null ) {
if (@$GLOBALS[‘mosConfig_pagetitles’]) {
$title_alias = trim( htmlspecialchars( $title_alias ) );
$title_alias = stripslashes($title_alias);
$this->_head[‘title’] = $title_alias;
}
}
// END CODE SNIPPET
============
Thanks to Phil, and you can read his original post here .