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:
- Go to "Global Configuration" and set the "Include site name in page titles" setting to "No"
- 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)
<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" />
- <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" />
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
Becomes
<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" />
- <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" />
If you preferred to put your website name first and then the page/article title:
<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" />
- <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" />
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):
- /components/com_content/views/archive/view.html.php (~line 83)
- /components/com_content/views/article/view.html.php (~line 121)
- /components/com_content/views/category/view.html.php (~line 115)
- /components/com_content/views/section/view.html.php (~line 88)
Joomla version 1.5.20
$document->setTitle( $params->get( 'page_title' ) );;
- $document->setTitle( $params->get( 'page_title' ) );;
to
$document->setTitle($mainframe->getCfg('sitename'). ' - ' .$params->get( 'page_title' )); // yields sitename - pagetitle
- $document->setTitle($mainframe->getCfg('sitename'). ' - ' .$params->get( 'page_title' )); // yields sitename - pagetitle
or Page Title then Website Name:
$document->setTitle($params->get( 'page_title' ) . ' @ ' . $mainframe->getCfg('sitename')); //yields pagetitle @ sitename
- $document->setTitle($params->get( 'page_title' ) . ' @ ' . $mainframe->getCfg('sitename')); //yields pagetitle @ sitename
Joomla version 1.5.14
to
$document->setTitle($mainframe->getCfg('sitename'). ' - ' .$article->title); //yields sitename - pagetitle
- $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