Friday, March 28, 2008

Home Tag Removal - Joomla Homepage Title

In the top of the home page in Joomla installation it reads the title of the page followed by Home. It is even picked by google and I often wondered why that tag is there from user's perspective. If you also have Joomla installation and want to remove it here is what you can do.

In Joomla installation directory, go to folder includes and locate joomla.php .

Search for setPageTitle. It is somewhere near the top 20% of the file.

Comment out the following lines:

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'];
}
}

Add the following lines just after:

function setPageTitle( $title=null ) {
if (@$GLOBALS['mosConfig_pagetitles']) {
$title = trim( htmlspecialchars( $title ) );
$title = stripslashes($title);
if ($title == 'Home') {
$this->_head['title'] =
$GLOBALS['mosConfig_sitename'];
}
else { $this->_head['title'] = $title ?
$GLOBALS['mosConfig_sitename'] . ' - '.
$title : $GLOBALS['mosConfig_sitename'];
}
}
}

2 comments:

Ekaterinburg said...

Hi, thanks for your post!
Is there a similar method of changing the home page title to a custom one?

Manish Verma said...

Hi Ekaterinburg, later on I realised that there is another problem with meta description related to the global metal description and home page meta description (Joomla 1.0.x). It looks like a better option to change the homepage itself. You can create a static page, link it to the main menu (it has to be the first main menu) and this can act as home page. This static page can have its own title which you have asked for and meta description as well.