Technology & Web Resources For Your Business
Home > Topic > How do I hide a node (page) title in Drupal?

How do I hide a node (page) title in Drupal?

Home Forums Tech Troubleshooting How do I hide a node (page) title in Drupal?

Post a New Topic

This topic contains 25 replies, has 3 voices, and was last updated by  Alex Schenker 4 years, 6 months ago.

  • Author
  • #10681

    How can I hide a page title in Drupal?

  • #10951


    Editing the template.

    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

  • #10956



    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!

    • #10959

      Alex Schenker

      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.

  • #10962


    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?

  • #10965


    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.

    • #10970


      For static content on front and 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.

  • #10967


    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.

  • #10973

    Alex Schenker

    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, 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; ?>

    <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.

  • #10938


    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.


    • #10940


      The problem is on page view the h1 tag doesn’t have a unique identifier, mnaybe does on your template. I have just made a quick fix to solved this problem in my template (based of garland).

      <?php if (!empty($title)): ?>nid ?>” id=”page-title”><?php print $title; ?><?php endif; ?>

      I basically added a class to the h1 tag called node- and added the php for the node object to call out the unique node id $node->nid. This gives you the advantage of being able to hide the node via css easily.

      Just needs replacing in your page.tpl.php file and then use this in your CSS.

      h1.node-(n) {diaply:none;}

  • #10942


    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.

    • #10945


      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.

    • #10949


      It’s because you never got into Drupal. Drupal has the strongest back bone (its structure and its vision). Once you understand CCK, filefields, imagefield, etc…, you will see the power of Drupal. It’s most definitely the future. I’m an ex-Joomla user, and develop sites ranging $30k-$300k, all based on Drupal’s CCK technique.

  • #10932


    In Drupal 6, use drupal_set_title(‘Access denied’);

  • #10934


    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??

    So close.

  • #10929


    Woot! Thank you very much this was extremely helpful.

  • #10922


    You can use the views module to hide node titles.

  • #10926


    Here’s why you’d need to hide node titles:

    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.

  • #10918


    Drupal is the most SEF (Search Engine Friendly) CMS we’ve ever used. Just be sure and redirect /node (core paths) or block them in robots.txt (our approach) so you don’t get duplicate content penalties when using “clean URL’s” (/this-is-a-clean-url) (/index.php?-23434 – that’s not).

  • #10920


    I am new to Drupal. I want to create a calendar page in which I can post events, their start date & time, and details. I’d like it to look like a monthly calendar, then the user can click on the event title for more details. I see there are many Drupal modules available, which require other modules to use, etc. Can someone tell me the exact modules I will need to install to create a calendar page?

  • #10912


    Try this solution: remember to add an h1 somewhere else on the page:

    if ($title != “<none>”)
    print ”.$title.”;

    then, just add “” to the page title and make sure other meta tags are being generated properly.

  • #10914


    Not sure why you’d want to hide the node title, as some others have said. I think you’re better of finding a way to style it using CSS so that you like the way it looks on your page. Your titles, headings, etc. are some of the more important structural/ SEO elements on your page, and should help your visitors read your content more readily, as well.

    • #10916


      Why some of us want to hide page titles:

      To be consistent with the rest of my page layout, I want to break my page titles into spans and then style each span differently (font color and font size).

      For example:
      (bold)Italian Delis(/bold)(line break)(smaller)in Culver City(/smaller)
      (bold)Country Inns(/bold)(line break)(smaller)in Santa Fe(/smaller)

      Can’t do this if I can only apply classes or styles to the entire h1 tag.

  • #10906


    Just hide it in CSS. Hide the title using your style sheet, so the search engines can still find your title. As mentioned in some thread above, the simplest way to do this is to use h1.title {display:none;} so your theme has no title, but Google still knows the name of each page. Very SEO friendly.

  • #10898


    Every page should contain an h1.

    You should always maintain a structured hierarchy of headings within any web page. You should never have a blank heading or even hide it with display:none;. Hiding any content which isn’t viewable by your visitors but is by search engines is against Google’s guidelines as your intention is to only manipulate search engine results by including it. Restyle a H1 so it fits into your design is the best option.

    If you still have to hide it then a better option would be to either create a template for that node, content type or page and simply not print the heading. Or if you want to use CSS then use position:absolute so the heading doesn’t use any space where it is located in the page and text-indent:-9999px; so the text is moved off the screen and no longer visible but at least can be read by screen readers.

You must be logged in to reply to this topic.