How do I customize the <TITLE> on all pages?

liza - January 14, 2006 - 03:30

I am going to try this one more time. We have tried to customize TITLE in order for it to show

SITE NAME | Title of the post

in the PHPTemplate

<title><?php print $head_title ?></title>

and in THEME.inc

  $output .= ' <title>'. (drupal_get_title() ? strip_tags(drupal_get_title()) : variable_get('site_name', 'drupal')) .'</title>';

Nothing works.

can you give us a bit more

coreyp_1 - January 14, 2006 - 04:45

can you give us a bit more info?

what theme are you using? If it is a custom theme, then what template engine are you using?

you said "I am going to try this one more time." does this mean that you have tried this before, or that you have tried to get help with this before?

changing theme.inc probably won't help, since your current theme is probably overriding it, anyway.

This is non-trivial

scrypter - January 14, 2006 - 10:09

I did this with my site when I converted to drupal about 6 months ago. You need to store the title you want for each page in the DB or use that formula you indicate. There is a module called nodewords which allows you to set keywords and meta-description for each page. I added title, but needed to hack various core scripts to get it working the way I wanted. Note that nodewords for 4.7 (or CVS) is significantly improved from 4.6. You are welcome to my code, it is not pretty, but it does what I want and it has paid off for Google, Yahoo and MSN.

www.scryptik.com - Javascript editor with syntax error checking

Fuddieish?

Bèr Kessels - January 14, 2006 - 11:54

Hi,

You state things that are not true. The fact that you did not manage to achieve this easily, does not mean that it *is* non-trivial. What you want it *very* easy, but requires some knowledge about the various theme hooks. I suggest you search for the hook_head and for how to print additional variales in your phptemplate. It is really easy.

---
Bèr Kessels
Professional www.webschuur.com
Personal bler.webschuur.com

theme.inc? phptemplate? what the hack are you hacking?

Bèr Kessels - January 14, 2006 - 11:52

You should never -ever- touch those core files for such trivial things.

quick example how to achieve this in bluemarine:
<title><?php print $site_name ?> presents: <?php print $title ?></title>
renders:
Laura S presents: My First Post

And if this helps you, I would be very, very pleased if you could show your appreciation by making this into a theme snippet in our handbooks.
---
Bèr Kessels
Professional www.webschuur.com
Personal bler.webschuur.com

book page

Dublin Drupaller - January 14, 2006 - 13:44

Just started a handbook page and snippet for theming the blogs

Dub

this is not a theme issue

liza - January 14, 2006 - 18:37

i've made the appropriate changes in the theme. this is an issue of how the TITLE information is output to the search engines; and unbelieveably, this looks like it's hard-coded in Drupal.

liza.

Bèr Kessels - January 16, 2006 - 10:18

You are doing it again:
I gave you an answer. Spent my time to explain in code how your problem could be fixed.

Next you comment that it seems not to work:
* without providing *what* you want to get to work
* without telling what I misunderstood, or did wrong

* But with telling that it is "unbelieveably, this looks like it's hard-coded in Drupal."

1: *what is hardcoded*? The title generation is handled by the theme. full stop. Nothing hardcoded!
2: what are you trying?

If you post harsh voiced comments, you can expect them back. So please be more friendly and polite if you want people to help you fix this problem.

It is not *we* vs *you*. we can also solve your problem together.

---
Bèr Kessels
Professional www.webschuur.com
Personal bler.webschuur.com

Why is this harder than it ought to be

liza - January 14, 2006 - 18:31

I am the publisher of the blog.
I am the marketer of the blog.

I own the blog.

Who ought to make the decision of where the name of the blog and the title appears in Google and other search engines?

Me.

Not Ber Kessel.
Not Dries Buytaert.
Not Kieran Lal.

This decision should squarely fall on me and only me.

Why in the world do you want to hard code this.
http://lizasabater.com/image/liza/drupal_code_madness

Anybody with basic knowledge of user interfaces will know that the left side is where you start looking at things on a browser --at least in most of the world that reads from left-to-right. This is the most important 'hot zone' of the browser.

I am in the business of bootstrapping the promotion of my brands and do so by all means necessary. That is why, as a publisher, I want the name of my blog to appear on the left side of the screen.

Why is this decision being made for me by Drupal?

try this..

Dublin Drupaller - January 14, 2006 - 18:49

Hi Liza..

Try this

in your page.tpl.php, at the very top where Drupal determines the page header change the bit that says <title><?php print $head_title;?></title>

to this:

<title>
<?php if (arg(0) == 'blog')
{print
// insert your customised page title tag here }
else {print $head_title;}
?>

</title>

See Bers post above for a tip on how to insert the customised header tag.

It could be something like this:

Liza's blog: How to use the search on drupal.org

as opposed to the default. Which is Node title : site name

if you want it to happen everywhere...just follow what Ber said above. the snippet I posted just changes the format on the "blog" nodes.

hope that helps

Dub

Thanks for the heads up but

liza - January 14, 2006 - 20:12

It still does not solve how Google is indexing the posts.

Sure it does

MrEricSir - January 16, 2006 - 11:02

Google indexes the very same page you see -- but it takes them time to do that. Their indexing software can only check your site so often with the millions (billions?) of pages it has to go through.

Note: If you have the google site map module you might want to make sure it's submitting page titles correctly.

it is not liza telling me what to do

Bèr Kessels - January 16, 2006 - 10:22

Liza. Really. you attacked me personally. If you cannot live with the way we work, then please move on, and stop ruining peoples mood by insulting them!

There are other CMSes out there. I suggest you look for a comercial one, so that you can pay people to do things you want them to do.

Bèr
---
Bèr Kessels
Professional www.webschuur.com
Personal bler.webschuur.com

Clarification and one solution (albeit an aesthetic one)

liza - January 14, 2006 - 20:31

There are two issues to this problem :

(1) How do you change what appear on the browser in the TITLE area. This is a cosmetic change.

(2) How do you change TITLEs so they'll appear a specific way on search engine results. This is the focus of my frustration.

For those of you wondering about the cosmetic change, the place to change this is in the PHPTEMPLATE.ENGINE file, which is found in /THEMES/ENGINES/PHPTEMPLATE.

Just find 'head_title' in the file and change this :

'head_title'          => (drupal_get_title() ? strip_tags(drupal_get_title()) .' | '. variable_get('site_name', 'drupal') : variable_get('site_name', 'drupal') .' | '. variable_get('site_slogan', '')),

To this :

'head_title'          =>  variable_get('site_name', 'drupal') .' | '.  (drupal_get_title() ? strip_tags(drupal_get_title()) : variable_get('site_name', 'drupal') .' | '. variable_get('site_slogan', '')),

When I changed this, I thought it would have an impact on how GOOGLE would index the titles of my site's entries. It hasn't. It's an aesthetic change that I really do not care for.

What I want is for GOOGLE to index all my site's entries with the name of the site first, the title of the entry second.

Is that too much to ask?

This is something I had total control with other blogging software. The decision was mine, not the software developers' decision.

slightly confused liza...can you help?

Dublin Drupaller - January 14, 2006 - 21:12

Hi Liza,

According to a few websites discussing search engine optimisation, the general consensus appears to be as follows:

When it comes to the order of the text in the title element, I’ve found that the following works well:

Document title | Section name | Site or company name

Based on a discussion here a while ago, that is probably one of the best formats for accessible title texts. Again, accessibility and SEO work together.

From 456bereastreet.com

Besides, I always thought google picked up the tag in HTML and if you change anything, you simply had to wait until google refreshed your indexed pages.

For example, let's say you wanted to reverse the order of your page header titles from "page title: Site name" to "Site name : page title"..but google had already indexed the default way. Wouldn't it take a period of time before google.com re-indexes your site?

Or do you have something that Controls what gets indexed in the robots.txt file?

the general standard appears to be what the guys at 456bereastreet.com specified. it would be good to know if you have an inside line on why the other way around is better.

Dub

It's a branding thing

liza - January 15, 2006 - 00:08

I want to differentiate my content from the rest. Having the name of the blog before the title is a good way of distinguishing content on the page when you have list of titles that look the same.

Many people have their theories about how SEO works.

What the engines do is one thing, but how people search for information and find it on a browser is very different. I am going for the eye-tracking factor here :

http://www.eyetools.com/inpage/research_google_eyetracking_heatmap.htm
http://www.webmarketingworkshop.co.uk/newsletter-april05.htm
http://ww1.prweb.com/prfiles/2005/02/28/213516/cropped.jpg

It does not matter whether I am right or wrong. The point is, it is not up to Drupal to decide where a blog's name appears on a Google search. That's a decision that ought to be left to the publisher.

sorry Liza...am Still confused..

Dublin Drupaller - January 15, 2006 - 01:01

hi Liza,

Thanks for the heads up on that, but, I'm still slightly confused. Sorry.

Are you saying that Drupal doesn't allow you to change how the site page headers are constructed?

Dub

it's an attention to detail thing

Phillip Mc - January 15, 2006 - 12:44

Hi Liza,

I think it's unfair of you to attack Drupal in such a way. describing drupal is "fascist" as you have done on your Drupal driven website is very narrow-minded. It's an attention to detail thing, not a branding thing.

if you think that it would improve Drupal, it would be very useful if you could

- submit a feature request to include an option on the Drupal site settings page for changing how page titles are displayed.

- Submit a handbook page here http://drupal.org/node/20639 which is a section of the handbook about "Helping search engines".

thankfully other Drupal users understand that Drupal is an open-source community developed tool and instead of slagging it off, they help to improve it either by submitting patches to bugs, handbook pages explaining how to do things or submitting feature requests.

philk

handbook page for this

Dublin Drupaller - January 15, 2006 - 16:31

Hi Phil,

Fow what it's worth...I have setup a new book page explaining how to change the way Drupal constructs the page header titles and a quick analysis of how some famous sites do it.

A simple search on this forum would have popped up an answer to the original query...so hopefully, the handbook page will help others in the future.

Worth noting that some of the bigger web sites like wikipedia.org, wordpress.org, drupal.org, nytimes.com, theregister.com, theonion.com among others use the same format as the Drupal default i.e. NODE TITLE | SITE NAME.

Hope that helps others.

Dub

Ummmmmmm, trivial

scrypter - January 14, 2006 - 21:22

Drupal does hard code the generation of <title> based on site name and posting title. This is quite good, but IMHO can be better. I am 100% with your post above about who sets the title. The title tag is the single most important on-page SE optimisation factor, and requires hand crafting.
I would hesitate before putting your site name at the beggining of the title tag, you may be better off putting it at the end or leaving it out.
My experience is not with blog entries but for pages. I accept that one should NEVER hack the core, but I have got good SERPs and that is more important to me. I would like nodewords to include <title> and it to be put in core, but this could be inflamatory!

www.scryptik.com - Javascript editor with syntax error checking

quick one..

Dublin Drupaller - January 14, 2006 - 21:35

interesting discussion

3 quick questions..

Do you use Drupals default tag, i.e. page title ¦ sitename or the reverse?

Do you use node search engine tags module?

do you use a robots.txt with Drupal?

Dub

Yes and No!

scrypter - January 15, 2006 - 01:37

No, I don't use default title tag.
Yes, but I have modified it to include title plus mods in core.
Yes, there is a robots.txt, vanilla, I would have to check what it contains.

www.scryptik.com - Javascript editor with syntax error checking

Thanks.

liza - January 15, 2006 - 00:11

This :

I am 100% with your post above about who sets the title. The title tag is the single most important on-page SE optimisation factor, and requires hand crafting.

is the key to this whole discussion.

Cache?

Thox - January 15, 2006 - 13:37

I can only guess that google is caching your page titles in some way. If you have already changed the output in the theme, could you check how new pages are indexed? I can see no way for google (or any other crawler) to use a title which doesn't appear on the page.

 
 

Drupal is a registered trademark of Dries Buytaert.