Drupal 7: Remove “No front page content …” message

Today, I noticed that that Google had found my website and the description showed the Drupal default message “No front page content has been created yet.” Definitely, the front page exists and contained content. However, I had not wanted to create an article page or other item and promote it to the front page. Therefore, Drupal was displaying that message. I had used CSS to hide the phrase, it seemed by a simple solution, but, hiding the content did not hide it from Google … Oops.

An option would have been to recreate the home page and in the administration area request the redefinition of the page to be used as the front page, a page that would not create that message. However, I did not want to recreate the page. I had already created several custom templates, including the page.tpl.php file. However, the message is embedded inside the $page content and printed by the line to render page content:

<?php print render($page[‘content’]); ?>

The question became, how do you remove the particular content and not damage the page as a whole. the answer is to unset the undesired content. the following command at the top of the page.tlp.php file removes the desired message without damaging anything else:


   
    <?php if(drupal_is_front_page()) {
              unset($page['content']['system_main']['default_message']);
          } 
     ?>

This same concept can be used to remove any unwanted text.

 

Leave a Reply