SEO core hack: [name of page - site name] in title

Your code modifications and patches you want to share with others.
Locked
User avatar
Sulpher
Joomla! Explorer
Joomla! Explorer
Posts: 264
Joined: Mon May 21, 2007 8:54 am
Contact:

SEO core hack: [name of page - site name] in title

Post by Sulpher » Sun Oct 04, 2009 5:26 pm

A lot of people have been recognizing that default title in Joomla! needs to be enhanced since SEO requires to make titles much flexible. Just an example on fingers on a page What is Joomla?:
Deault page title is What is Joomla? and site name is Joomla!.
We'll do next title: What is Joomla? | [Joomla! (page name | website name)

It's really easy to do.
1. Open the file libraries\joomla\document\html\renderer\head.php, find the line #53:

Code: Select all

function fetchHead(&$document)
    {
 
and add next line:

Code: Select all

global $mainframe;
        $SiteName    = $mainframe->getCfg('sitename');
 
so, then find the line:

Code: Select all

        $strHtml .= $tab.'<title>'.htmlspecialchars($document->getTitle()).'</title>'.$lnEnd;
 
and replace it on next one:

Code: Select all

        $strHtml .= $tab.'<title>'.htmlspecialchars($document->getTitle()).' - '.$SiteName.'</title>'.$lnEnd;        
 
That's all.
Templates for Kunena, JComments, AcyMailing & ZOO Apps - https://www.roundtheme.com
Joomla! extensions provider - https://www.norrnext.com

Eugene Sivokon - follow me @sulpher

Locked

Return to “Core Hacks and Patches”