PHP Code, SEO Optimization

How to remove the site name from the title in Joomla

Create beautiful Joomla websites with a flexible layout from iJoomla.com

I recently realized that every single page created by the default Joomla installation includes the site name in the page title, even before the title of an article itself. This can be both annoying AND harmful to SEO efforts. I looked around for a setting to disable this, but found out that this has to be manually removed in the PHP coding of the CMS itself.

You need to locate the file [install_dir]/includes/joomla.php, and find the function setPageTitle, which should be on line 468.

Change this line:


	$this->_head['title'] = $title ? $GLOBALS['mosConfig_sitename'] . ' - '. $title : $GLOBALS['mosConfig_sitename'];

to


	$this->_head['title'] = $title ? $title : $GLOBALS['mosConfig_sitename'];

So now the whole function will look like this:


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

Create beautiful Joomla websites with a flexible layout from iJoomla.com

Share

5 Comments

  1. cheers for that dude.

  2. Thanks so much for this! I've been wondering how to do make this change. Now, what if you still want the site name, but after the page title? Sorry, to be dense, but I am a reletive newbie to php.

  3. set it to:
    $this->_head['title'] = $title ? $title – $GLOBALS['mosConfig_sitename'] : $GLOBALS['mosConfig_sitename'];

  4. @ Justin Cook:

    set it to:
    $this->_head['title'] = $title ? $title – $GLOBALS['mosConfig_sitename'] : $GLOBALS['mosConfig_sitename'];

    this code names my title to '0'. Do you have a suggestion how to make this work?

  5. Found a way to go through settings
    http://forums.powweb.com/showthread.php?t=80972

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image