The title tag on the Blog module index page (found at /blog after the module is installed) is by default "Blogs | Sitename", which isn't editable in the backend of Drupal. I've been talking to other Drupal developers and reading forums about the best way to go about changing the title of the blog index page. Ideas ranged from editing or duplicating the blog module (which is bad practice) to installing the String Overrides to provide a quick translation of the string in the title.
These suggestions are either quite poor, or simply overkill for what should be a simple string replacement. There were two methods we decided upon that work quite well and are easy to implement.
1) The first involves creating a page-blog.tpl.php template file and adding a str_replace() function call to replace the word blog from the title of the page. This would look something like this:
<title><?php print str_replace('Blogs | Sitename', 'Blog | Sitename', $head_title); ?></title>
I have entered the entire site name here as this cuts down on changing the title on legitimate blog posts containing the word "blog". The only limitation here is that this will need to be altered every time the title changes. This, however, shouldn't be very much and so is fairly robust solution on most cases. A few false positives might occur in the future with some blog titles, but these should be minimal.
2) The second method involves the use of the page variable $vars['head_title'] in the template.php file, which changes the $head_title variable before it gets to the template. This is done by using the hook_preprocess_page() hook and checking the value of arg(0) to make sure it is 'blog', which will be the case only on the blog index page. Create the following function in your template.php file in your theme and rename it so that it is inline with your own theme name.
/**
* Override or insert variables into the templates.
*
* @param array $vars The array of variables to pass tothe the theme template.
*/
function theme_preprocess_page(&$vars, $hook) {
if (arg(0) == 'blog') {
$vars['head_title'] = str_replace('Blogs', 'Blog', $vars['head_title']);
}
}
The arg(0) function will only ever return 'blog' if we are looking at the blog main page. So a simple find and replace here is enough to change the title and won't effect any blog post title. It might also be worth checking that the length of the array returned by arg() is 1 to make absolutely certain that this is the index page.
Which method you chose here depends on your own preferences, but I think that the second is more robust and maintainable than the first. The second method also doesn't require a separate blog page template, which is pointless if you are only changing a single variable.
There might also be other ways in which the title tag can be changed. If you know one and want to share it with us then post a comment.
Update: This post is specifically for Drupal 6 and so might not work for other versions of Drupal.
Ben Leivian