I'm using Garland and I wanted to change the header title-tag from PAGENAME | SITENAME to just PAGENAME.

I changed part of the page.tpl.php

FROM:

print $head_title

TO:

print $title

THIS WORKED FINE,

Every page except the front page now has the title-tag PAGENAME as I wanted

BUT

My front page shows no title-tag at all.

I want to keep the amended code, and keep the PAGENAME as the title-tag for all other pages,
but I also want to have the SITENAME for the title-tag on my front page.
How do I change my new code to achieve this?

Can anyone help with the correct code?

Comments

pinky.evakoss’s picture

Hello,

you can use page_title module. it provide settings for front page and other pages. you can have different page title instead of node title for the nodes.

Regards,
Pinky

anotherdave’s picture

Hi,

The $head_title variable prints the page name, followed by a pipe (|), followed by the site name. The $site_name variable prints out the site name on it's own in the same way that $title variable prints the node title on its own.

If you're using Garland, you should have a file page-front.tpl.php - what is in between the <title> tags here? You should be able to put <?php print $head_title; ?> or <?php print $site_name;?> here, which will hopefully fix that problem.

Just to point out that having both the node title and site title is generally seen as best practice for SEO and usability, but it's up to you.

All the best
Dave

anotherdave’s picture

As a PS, when starting I found this page invaluable:

Also check out the ones for node.tpl.php, comment.tpl.php, etc.

All the best
Dave

David Ipswich’s picture

Thanks.

I've taken your SEO advice and changed the code back to what it was originally.

I'm also taking your recommendation and will do a bit of bedtime reading.

Thanks everyone.

anotherdave’s picture

Cool, glad to be of help.

Dave

pinky.evakoss’s picture

if you want to do this by code, you can try this


if (drupal_is_front_page()) {
  print $site_name;
}
else {
  print $title;
}