Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to change the title head of the pages in Drupal 7 by path. NOt to all content type. I need to change the title head to a specific page generated with views.

For example, I have a site http://www.mysite.com

<title>My favorite website </title>

I need the for pages:


<title> My test today </title>


<title> My examples for share </title>


share|improve this question
I'm not sure what you mean by "change the title head to a specific node." Could you clarify please? Two common modules that help in this area are drupal.org/project/pathauto and drupal.org/project/auto_nodetitle You might check them out and if they don't work, explain how your use case is different than the ones these common modules handle. – Patrick Kenny Mar 5 '12 at 15:48
I refer to the "title head" that appears in the meta tags. The title that is shown in the tabs of the browser. Thanks. – cabita Mar 5 '12 at 16:01
up vote 9 down vote accepted

Here is how I did it in Drupal 7.

In template.php:

function YOUR_THEME_preprocess_page(&$vars){
  $path = $_GET['q'];

  if (strpos($path,'YOUR_PATH_STRING') !== false) {

For example, if your path was yoursite.com/boogabooga, then you would set 'YOUR_PATH_STRING' to 'boogabooga' and 'YOUR_TITLE' to whatever you want the page title to be.

share|improve this answer

It sounds for your limited set of pages maybe implement THEME_preprocess_html() and examine the url path and override $vars['head_title']. See this blog post as an example: How to set custom page title in Drupal 7

If you have some patterns for the head title try Page Title

share|improve this answer
I saw the post and I have a question, if I want to assign a "head title" to the specific paths. Not to all paths will have the same title. For example I need mysite.com/test the <title> is "My tests" and I have other page mysite.com/examples I need that <title> "Examples for share". Is this code useful for this purpose? I have updated my post. – cabita Mar 6 '12 at 13:23
@cabita Tenken's post covers your use case. Besides what he already mentioned you can also use the Meta tags module. All 3 options allow you to set the head title for the specific node pages you want without touching the rest. – Dooshta Mar 6 '12 at 23:03
I tried with meta tags and allow change the title head for specific pages but no for specific pages generated by views. I will update my question again. I'm sorry. – cabita Mar 6 '12 at 23:17
@cabita Did you also try Page Title? It at least claims to have views integration. If this doesn't work out either you could just go ahead and do it in the code (it's easy to restrict changes to specific pages only by using $_GET['q'] or arg() to check the path). – Dooshta Mar 6 '12 at 23:33
I did in the code. You are right, it's easy to restrict changes to specific pages only by using $_GET['q'] or arg(). – cabita Mar 7 '12 at 11:15

Your Answer


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.