Take the 2-minute tour ×
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It's 100% free, no registration required.

In the Joomla 2.5 Global Configuration under SEO, there is the option to "Include Site Name in Page Titles", with the options "After", "Before" or "No". However, how do you include the site name ("After") on all pages except the front page? (And perhaps for other pages as well?)

This is on Joomla 2.5, however, I would also like to know if the process is any different in Joomla 3.

Core functionality or manual code solutions are preferred. However, if there are suitable extensions that provide this functionality then please feel free to suggest these as well.

share|improve this question
1  
I don't know for sure, but I suspect the answer is that you can't without an extension (or a mod to the template). I'm curious to know the answer myself :) –  Brian Peat Apr 29 at 20:17

5 Answers 5

up vote 5 down vote accepted

To set the title of the frontpage differently from the other pages title, add the following code to the template index.php file towards the end of the head information.

$menu = $app->getMenu();
    if ($menu->getActive() == $menu->getDefault()) {
    $this->setTitle( 'Whatever You Want Title' );
    }

This code will set the frontpage title independently of the way Joomla sets the rest of the pages. This works on Joomla 2.5 and I believe it will also work in the 3.x series.

share|improve this answer
    
Thanks, this was actually the method I ended up using - works well. –  w3d Apr 29 at 23:54

Four options here: A) use Joomla's native before, after or no. Then go into your home menu item and add a browser title. It will STILL use the before, after or no, but at least you get a custom name out of it. So it'll look like:

Providing Service for 100 Years - Company Name

B) Add this code below your open body tag:

 <?php 
 $app = JFactory::getApplication();
 $this->setTitle($this->getTitle().' | '.$app->getCfg('sitename'));
 ?>

This gives you the option of using pipe breaks instead of the dash, or some other character of your choice. You can also instead of using sitename, can put something else in there and have it append to all browser titles.

Providing Service for 100 Years | Company Name

C) Set your Joomla to no. Manually write all menu item browser titles. Not horrible for smaller sites. Really awful for larger sites.

D) I haven't tried this, but I think it would work. In theory anyway. Add an id to your homepage.

This goes above the doctype:

<?php
  $app = JFactory::getApplication();
  $menu = $app->getMenu()->getActive();
  $pageclass = '';

  if (is_object($menu))
    $pageclass = $menu->params->get('pageclass_sfx');
?>

And this replaces body

<body id="<?php echo $pageclass ? htmlspecialchars($pageclass) : 'default'; ?>">

Now add a class to your menu item. It will show up as the body ID. NOW, use the code provided in option D, and throw a php function around it prevent it from running on the body ID of your home page (sorry I don't know how to write php or I'd do it for you), then fill in the browser title in your home menu item. Everything else will get your site name appended, but the home page.

share|improve this answer
    
Thanks for all the suggestions. To be honest I'm not sure how D would work? I can see that this could be used to change an in-page title with CSS perhaps, but I need to actually write to the TITLE element. In the end I've ended up using a hybrid of your B and D suggestions to first check that the currently active menu is the "default" (ie. we are on the front page) and then calling setTitle() to manually override the title just for the front page. –  w3d Apr 30 at 0:05
    
I mean use the id as an element in a php statement that says "if this body has this id, don't include this code that adds the site title". But hey, if my ramblings gave you an idea, run with it! –  REactionFaye Apr 30 at 14:33

As far as I know, there is no such option for individual pages.

I have never try this on the core joomla, but I have used a plugin named "SEO generator" in the past, which has options for customizing the page titles by adding the site name (similar to the joomla core options), with some extra settings for a custom front-page page title.

But if you want to do the same for more pages, this plugin will not do it, unless if you modify its code and make it check for specific menu-items by id that you want to apply the extra site name.

There might be other extensions that could offer admin management of menu items that you want to have special settings regarding the page title, but I don't know any to name.

Of course, there is always the manual way where you can write your desired title for each page.

However SEO concerning, using the site name in all these pages, isn't always the best idea.

share|improve this answer

RS SEO can do this out of the box. In the configuration you set up how you want the site title added, then you can edit any page you want once it has been added. This is particularly important for pages that have long titles that would be too long if you add the site name to the title.

share|improve this answer

I made a module that you can assign to any page and override meta title and description (It's actually for adding custom code to a site and extra code to the page head but it does this as well).

http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/custom-code-in-modules/17842

Set global configuration how you want most of the site to be and then use the module to target specific pages.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.