Add the website name to the page title in Joomla!

Change Page Title in Website
Here are some instructions on changing the page title in Joomla! CMS to display both the actual page title and other stuff. As I like doing this for this particular website (my personal one) in every version of Joomla it's been upgraded to, I've noticed some differences that I've noted down below.

Specific Joomla Template Providers

Everytime I update this article, Joomla seems to come out with a new version. If you have installed Joomla 2.5, this is now a setting in the global configuration... The only problem is that your landing page becomes "HOME - SITENAME.COM" which is ridiculous and I'm sure Joomla will release a new version addressing this.

In the meantime however:

  1. Go to "Global Configuration" and set the "Include site name in page titles" setting to "No"
  2. Open your templates component file (in the case of Yootheme using the Warp Framework this is \templates\<yoo_template_name>\warp\systems\joomla\layouts\head.php, in the case of others this is \templates\<template_name>\index.php)
copyraw
<head>
<?php
	$exception_page = "Home";
        $app = JFactory::getApplication(); // optional line if it isn't already in file

	if (trim($this['system']->document->title)!=trim($exception_page)) { 
		$new_page_title = $this['system']->document->title . " - " . trim($app->getCfg('sitename')); 
		$this['system']->document->title = $new_page_title; 
	} else {
		$this['system']->document->title = trim($app->getCfg('sitename')); 
	}
?>
<jdoc:include type="head" />
  1.  <head> 
  2.  <?php 
  3.      $exception_page = "Home"
  4.          $app = JFactory::getApplication()// optional line if it isn't already in file 
  5.   
  6.      if (trim($this['system']->document->title)!=trim($exception_page)) { 
  7.          $new_page_title = $this['system']->document->title . " - " . trim($app->getCfg('sitename'))
  8.          $this['system']->document->title = $new_page_title
  9.      } else { 
  10.          $this['system']->document->title = trim($app->getCfg('sitename'))
  11.      } 
  12.  ?> 
  13.  <jdoc:include type="head" /> 

Note: If you are having difficulty locating this, then simply search your template files for "<jdoc:include type="head" />" (without the quotes) and carry out the above process (TESTED for J1.6, J2.5, J3.0)

Joomla version 1.6.x to 2.5.x

I'm not sure whether I could do this in earlier versions of Joomla but I was making my first Joomla 1.6 template and realised I could include this tweak in the actual template. Open /templates/<name_of_template>/index.php and insert the following just after the <head> tag and before the <jdoc:include type="head" />:

So

copyraw
<head>
<jdoc:include type="head" />
  1.  <head> 
  2.  <jdoc:include type="head" /> 

Becomes

copyraw
<head>

<!-- The following appends the site name to every page title except my Homepage (called Home) -->
<?php
	$exception_page = "Home";
        $app = JFactory::getApplication(); // optional line if it isn't already in file

	if (trim($this->title)!=trim($exception_page)) { 
		$new_page_title = $this->title . " - " . trim($app->getCfg('sitename')); 
		$this->title = $new_page_title; 
	} else {
		$this->title = trim($app->getCfg('sitename')); 
        }
?>

<jdoc:include type="head" />
  1.  <head> 
  2.   
  3.  <!-- The following appends the site name to every page title except my Homepage (called Home) --> 
  4.  <?php 
  5.      $exception_page = "Home"
  6.          $app = JFactory::getApplication()// optional line if it isn't already in file 
  7.   
  8.      if (trim($this->title)!=trim($exception_page)) { 
  9.          $new_page_title = $this->title . " - " . trim($app->getCfg('sitename'))
  10.          $this->title = $new_page_title
  11.      } else { 
  12.          $this->title = trim($app->getCfg('sitename'))
  13.          } 
  14.  ?> 
  15.   
  16.  <jdoc:include type="head" /> 

If you preferred to put your website name first and then the page/article title:

copyraw
<head>

<!-- The following appends the site name to every page title except my Homepage (called Home) -->
<?php
	$exception_page = "Home";
	if (trim($this->title)!=trim($exception_page)) { 
		$new_page_title = trim($app->getCfg('sitename')) . " - " . $this->title; 
		$this->title = $new_page_title; 
	} else {
		trim($app->getCfg('sitename'));
        }
?>

<jdoc:include type="head" />
  1.  <head> 
  2.   
  3.  <!-- The following appends the site name to every page title except my Homepage (called Home) --> 
  4.  <?php 
  5.      $exception_page = "Home"
  6.      if (trim($this->title)!=trim($exception_page)) { 
  7.          $new_page_title = trim($app->getCfg('sitename')) . " - " . $this->title; 
  8.          $this->title = $new_page_title
  9.      } else { 
  10.          trim($app->getCfg('sitename'))
  11.          } 
  12.  ?> 
  13.   
  14.  <jdoc:include type="head" /> 

This means you don't have to do as many changes as described below. Modifying just one file with these few lines of code inserted should work.

 

Previous Joomla versions

eheimer suggests this (Source: http://forum.joomla.org/viewtopic.php?p=974395) which worked for me after a few tweaks. I've rewritten this so that it helps me because the original text didn't apply to Joomla version 1.5.14.

 

This puts your website name in front of every page title seperated by a hyphen.

Modify the following files with the below code change (exclude the FrontPage one):

  1. /components/com_content/views/archive/view.html.php (~line 83)
  2. /components/com_content/views/article/view.html.php (~line 121)
  3. /components/com_content/views/category/view.html.php (~line 115)
  4. /components/com_content/views/section/view.html.php (~line 88)

Joomla version 1.5.20

copyraw
$document->setTitle( $params->get( 'page_title' ) );;
  1.  $document->setTitle( $params->get( 'page_title' ) );; 

to

copyraw
$document->setTitle($mainframe->getCfg('sitename'). ' - ' .$params->get( 'page_title' )); // yields sitename - pagetitle
  1.  $document->setTitle($mainframe->getCfg('sitename')' - ' .$params->get( 'page_title' ))// yields sitename - pagetitle 

or Page Title then Website Name:

copyraw
$document->setTitle($params->get( 'page_title' ) . ' @ ' . $mainframe->getCfg('sitename')); //yields pagetitle @ sitename
  1.  $document->setTitle($params->get( 'page_title' ) . ' @ ' . $mainframe->getCfg('sitename'))//yields pagetitle @ sitename 

Joomla version 1.5.14

copyraw
$document->setTitle($article->title);
  1.  $document->setTitle($article->title)

to

copyraw
$document->setTitle($mainframe->getCfg('sitename'). ' - ' .$article->title); //yields sitename - pagetitle
  1.  $document->setTitle($mainframe->getCfg('sitename')' - ' .$article->title)//yields sitename - pagetitle 

Or you can download a plugin that does this for you... It's FREE but it might add to the page loads more than the above change:

http://extensions.joomla.org/extensions/site-management/seo-a-metadata/3352 [Extension:Website Name] 

Similar Searches:

  • Browser title - how to add website's name
  • Joomla Title Manager
  • SEO core hack: [name of page - site name] in title
  • SEO: Page Title and Site Name
  • change head title to remove HOME
  • Remove HOME from HOME - SITENAME
  • page title home website joomla
  • change page title joomla
  • change website title joomla
Category: Joomla :: Article: 169

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.