Driver Robot Speeds & Cleans up Your PC Automatically

Driver Robot automatically downloads the latest drivers for your PC and keeps it running smoothly. Inject new life into your old PC and fix existing problems instantly. Run a free driver scan now and put your PC back in business.

 

Buy One Domain Name, Get One Free

Looking for a reliable and affordable Domain Name Registrar? Look no further than Dotster. And for a limited time, we're able to offer our visitors a buy one domain name, get one free promotion. Click here to take advantage of this offer.



Apr 03 2009

Drupal - Hide Node Title


Filed under: Content Management Systems » Drupal,
Tools:


Want to hide a node or page title in Drupal?

Don't like having a title on top of your Drupal page? Some layouts simply look better without a title, or maybe you are building a page where a title just doesn't make sense. Whatever the reason, not being able to control the presence of a page title in Drupal can be annoying. For those that are new to Drupal, the terms node and page, for the sake of this article, can be considered one and the same. (A page is actually a type of node).

The blank space no longer

In older versions of Drupal, you were able to circumvent the need for a page title by simply entering a blank space (spacebar key). The space would register and the page would output without a title. You could not simply leave the node title blank, however, as this would throw an error. Unfortunately, entering a whitespace character no longer works. Newer versions of Drupal don't allow it anymore (you'll see an error telling you not to leave the node title blank).

A title helps with SEO

One of the most direct, obvious advantages of a page title is that it helps with SEO (Search Engine Optimization). If you're interested in learning more about SEO and search marketing, we invite you to visit our sister site, GuruofSearch.com. Typically, a well organized page that is ready to be indexed by search engines has a title tag and heading tags, with the page title contained in the top most heading tag, the h1 tag. However, if you leave your node title blank, or use the following method to leave out your node title entirely, you'll be missing this h1 tag. This is not necessarily a problem, as long as you manually add it back when you're writing your page content.

It's also worth noting that the method below retains your page title. The old method of simply inserting a blank space for the node title left you with an empty page title (the title that shows up in the heading bar of your browser window). The method below will retain your page title, as it allows you to enter a title for your page, yet not have it show up in h1 tags above your content. So, the top of your page will begin with what you type in the top of your editor window (the body), it will not contain anything, such as the page title, auto-generated by Drupal.

How to create a Drupal page with no title

One of the advantages of creating a node (page) with no title is that it lets you fully customize your page. Drupal won't be auto-generating any content that's not under your control. Use the following snippet in your page.tpl.php or page-front.tpl.php (for the front page) in place of the line that prints your title tag.

  • Old (Bluemarine theme)
    • <h1 class="title"><?php print $title ?></h1>
  • Old (Garland theme)
    • <?php if ($title): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; endif; ?>
  • New:  
    • <h1 class="title"><?php if ($title == "") print $title ?></h1>

What does the no node title code do?

So how does the code above work - what does it do exactly? You're basically asking the question: "If the page title is blank..." print the title within h1 tags. Since Drupal doesn't let you leave a blank title, the page title will never print out. Instead, you can fill in a descriptive title for your own reference, and the page title will still print in the title tags of your page, which is important for SEO. You can then add the page title, or a similar title of your choosing, back yourself within the body content, and, preferrably, within h1 tags.

Average: 3.9 (13 votes)
Tools:



use Views

you can use Views to hide node titles.

I'll tell you why

I'm using the CCK to build a basic web app / database. I don't want or use the Title or Body.

Googling for "Drupal hide title" gives many results of others wanting the same thing. In my mind this reflects poorly.

All CCK fields should be treated the same... "title" and "body" shouldn't be magic.

Woot

Thank you very much this was extremely helpful

Drupal 6

drupal_set_title('Access denied');

I also need it on the front page

Works well when on the node itself.

Except for me I'm trying to hide the node title, which is sticky and promoted on the front page. Someone said I need a front-page template file?

How do I make one? My theme (Waffles) does not have one. Can there just be an if statement that checks if it's on the front page? If so what would it be??

Soo close

Use Stylesheet instead

Although I'm not a Drupal expert, I think that instead of altering the page.tpl.php or.tpl.php, modifying the stylesheet can solve the SEO problem. The title then will be there in the code, still, but just not shown on the actual page.

Depending on the theme you're using (I'm using Alek 2.0), you can alter the style.css. Find the section responsible for the title (in my case : .nodeTitle, .pageTitle {... }, and add 'display: none;' Correct me if I'm wrong.

Cheers,
Mark

Joomla is Better

I do not understand why Drupal people claim that it is so much better than Joomla. Drupal is crap from my personal experience. The only advantage with it over Joomla is that it is far more lightweight.

I have mastered Joomla and can customize every aspect of it. The way Drupal is designed is by no means great. Come on people, stop the anti-Microsoft, anti-Joomla, anti-popular mentality.

Joomla is mainstream for a reason.

Why Oh Why

I do not understand what compels people to "write product X is so much better than what you are using".

If you have nothing useful to contribute to the discussion then stay out of it.

Editing the emplate

I had a few problems with editing the template. I realized that I would like to keep the title up because it's much easier for my readers to understand the subject.

Best Regards
Jay Pleas,
work at home blogger

Front page

Hi

This is great, it has worked for most of my site, but it has not worked for my front page. Please can you tell me what I need to do for the front page?

I have called the front page "____________" so it appears as a line going across the page as a temporary ugly fix.

Please help!

Front page template

Your theme should have, or if it doesn't, you can create it - a template file specifically for your front page, named page-front.tpl.php. Make sure you make the appropriate edits in this file as well.

Maybe I'm Missing Something But...

I like (perhaps need would be a better word) to have the ability to put separate content in the Title (tag) and the H1 tag. Here's why:

1. While not likely to trigger any type of duplicate content penalty (of late everyone says there isn't any such thing from Google), the search engines don't generally index the same content twice. Even though you'd think this applies between pages, it's reasonable that they may exclude the duplicated content within pages. Using separate wording for both the title and H1 could give you a better stance.

2. I like to have all the opportunities possible to include long tailed versions of the keywords I'm going after, so each area gets a different version/permutation/localization.

Is this what the debate is about?

I agree, I don't understand

I agree, I don't understand why anyone would want to hide the node title, as it helps establish a solid SEO structure. If it's a layout/ design issue - I would simply restyle the look of the title.

Drupal Node Title Flexibility

If you spend some time exploring CCK (Content Creation Kit) and Contemplate - you'll see that together with Drupal's native theming capabilities (using template.php and the theme files), you can create just about any setup that is SEO friendly, including one that doesn't "show" the node titles.

Why hide Drupal node title?

I agree, I don't understand why anyone would want to hide the node title, as it helps establish a solid SEO structure. If it's a layout/ design issue - I would simply restyle the look of the title.

static content on front/home pages

Because having a big "Front" or "Home" in h1 at the top of your home page just looks dumb, regardless of what font or styling you use.

Now, if your front page is a listing of the latest "promoted to front page" items, then yeah, you want titles. But not every site is like that.

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <br> <br />
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options

CAPTCHA
This question is used to make sure you are a human visitor and to prevent spam submissions.