Community

How do I hide the page title on my home page?

Heya,
How do I hide the page title on my home page?

Comments

two ways, css and php

You can set its css to display: none;

Or you can find the code in the page.tpl.php template in your theme and delete or preferably comment out the code - or try looking in template.php and node.tpl.php

(always remember to back up the original files in case it doesn't work the way you planned!)

I think using css is preferable

I am working on a site with ALL the Drupal features hidden on the front end - for now we're using the back end - I think we will eventually want the community plumbing, so then it'll be easy to roll it out.

About half of the hiding is done with css, some had to be done in the php templates

The pages are made up of individual nodes assembled sort of like php includes

http://jcat.netsperience.org/

I also had to create a dedicated admin page for login and site management.

~are you netsperienced? http://netsperience.org

Oh you know I meant how to

Oh you know I meant how to hide it only on the home page. As you probably know already display: none hides the title tag on every page, as would deleting the statement.

Thanks!

Spence
http://www.spencerhill.us

how about javascript?

Use some js to test the location and hide/display accordingly...

<script language="javascript">
If (location=="your_home_page_url") getElementById("titleid").style.display="none";
</script>

replace titleid with id of title in your theme that you want to hide-

should work....

haven't tested it, but give it a try

~are you netsperienced? http://netsperience.org

Another approach, at the top

Another approach, at the top of page.tpl.php add

<?php
if ( $is_front ) {
  unset(
$title);
}
?>

this will unset the title when view the front page (so it should not print).

use the php code

Yeah, I think the php solution looks better

Is there a list of Drupal variables and tokens somewhere on this sprawling site, and tips on manipulating them?

~are you netsperienced? http://netsperience.org

For Drupal 5 see:

For Drupal 5 see: http://drupal.org/phptemplate. Each of the links to a tpl.php file (ex: node.tpl.php) will list the variables available in that template.

Yeah PHP is the way to go in

Yeah PHP is the way to go in my opinion. But I inserted that statement and created a $title = 'home' but it didn't remove it... Can you show me an actual live excerpt?

Thanks!

Spence
http://www.spencerhill.us

What do you mean by "created

What do you mean by "created a $title = 'home' ", you mean you created content with the title 'home'. Unless you make the content the default front page the title will show when viewing it.

I mean I made the following

I mean I made the following modification to the PHP you gave me and inserted it in the head of page.tpl.php:

<?php
$title
= 'home'

if ( $is_front ) {
  unset(
$title);
}
?>

Thanks!

Spence
http://www.spencerhill.us

I added a semi-colon after

I added a semi-colon after $title = 'home' and placed the code segment right at the start of page.tpl.php and it worked fine.

Hm... still doesn't seem to

Hm... still doesn't seem to be working for me... You mind taking a look at the site and the code for it?

http://www.spencerhill.us/green-dragon

You'll notice the linked title "Intro" at the top. That's what I'm trying to hide.

Thanks!

Spence
http://www.spencerhill.us

It's not a page title :)

I would guess you are using the default front page (node) and promoting a single node to the front page. Try changing the front page to be just that node (ex: node/123, the 123 will be different for you). You can do this by visiting "Administer" > "Site configuration" > "Site information" and setting "Default front page".

You are the man. That was

You are the man. That was it.

Thanks!

Spence
http://www.spencerhill.us

Good Solution

This is a good solution in that it allows you to specify the title of the page in order to single it out by the actual text of the title. However, that's also it's drawback, because what if you change that title? You now have to make sure every page you promote to uses the name you specified in the tpl. But it's still a clever kluge.

Thanks..

This worked for me , with box_grey theme.

...disables RSS

I have discovered that hiding the node title has the side-effect of disabling RSS. Has anybody ran into this? Any ideas how to still hide the node title from my home page while keeping RSS enabled?

I hadn't noticed that,

I hadn't noticed that, either, but you're right!

RSS feed is gone now! How do we get that back?

I added rss to the sidebar,

I added rss to the sidebar, but I'm not sure if the code is suppressing the front feed or not

Hello...this technique worked well for me..but i have another doubt. How to remove ' Posted Sun, 06/06/2010 - 17:32 by Anonymous ' just below the title?

I've tried your approach on

I've tried your approach on page.tpl.php and page-front.tpl.php but I can't seem to get this to work. Do you know if there's anything different I need to do if working on a zen sub-theme?

easy in Zen

You are in luck because Zen makes it super easy. There is a class called "front."

Classes on body include items like "logged-in", "not-logged-in", "front"...

So something like:

.front .title{
   display:none
}

is the quick solution to your problem.

A list of some of the Drupal sites I have designed and/or developed can be viewed at http://motioncity.com/drupal

thanks

Useful

Liam Ke

I found another method

I found another method useful on my site: create a specific node.tpl.php file for just the node(s) appearing on the front page. Details here: http://drupal.org/node/136647.

Anthony

I opened a feature request

I opened a feature request for this at #639966: Let us hide title on default front page.

Thanks--Good Idea

I read some of the comments over there. Seriously? How could anyone not think this is a good idea, a most basic feature that should be there. Jeez.

Ok, yes, I come from Joomla too, but I've gotten pretty deep into Drupal too and it's earned quite a bit of respect. This is just such a basic feature to me I find myself really surprised there is no such built-in functionality in it.

page-front.tpl.php

Instead of unset($title) which erases variables, why not copy your page.tpl.php to page-front.tpl.php.

At the top of the page-front.tpl.php, don't print the $title, eg at the top of page-front.tpl.php:

<head>
  <!-- <title><?php // print $head_title; ?></title> -->
  <?php print $head; ?>
  <?php print $styles; ?>
  <?php print $scripts; ?>
</head>

Joe
http://www.hydeinteractive.com/

why comment it out?

@jghyde

<head>
  <?php print $head; ?>
  <?php print $styles; ?>
  <?php print $scripts; ?>
</head>

is a cleaner way...

Not very good SEO to leave

Not very good SEO to leave the title tag out of head. Note this does not change the printing of $title on the page which is what the original question is about.

good point

@nevets

you're right, this affects the DOM title but not the page title...

I have also found that when CSS alone cannot be specific enough, a bit of jQuery can work miracles eg #807014: exclude specific users and roles (eg admin) from public User List

Using php in page.tpl.php

Here is how I solved this issue, using page.tpl.php:

<?php if (!$is_front): ?>
<h1 class="title" id="page-title"><?php if (!empty($title)): print $title; endif; ?></h1>
<?php endif; ?>

It's good form that you check that title is set...

I like the style you use with testing that the $title isn't empty before trying to print it. However in the unusual circumstances that you have a page with no title, do you really still want to print an empty <h1> tag-set into the page?

It might be an improvement to put the IF statement around the whole thing and/or combine the nested IF-statements, e.g.:

<?php if (!$is_front && !empty($title)): ?>
  <h1 class="title" id="page-title"><?php print $title; ?></h1>
<?php endif; ?>
About me:

An Omega Sub-theme has settings in "Toggle advanced elements" to hide the Page Title, Site Name, Site Slogan with CSS while leaving them accessible to screen readers.

see http://drupal.org/node/1298698

Yet another way :D

Hide Home Page Title Only

This worked like a charm; thanks!

kRemtronicz - San Diego Web Design & SEO

Succeeding in Helping YOU Succeed!