Nobody wants an empty frontpage. Drupal assumes you create content, once you do so the message disappears automatically. By default Drupal displays all nodes that receive the "promote to frontpage" setting. This leaves you with a blog-style list of teasers of all published nodes. Often this is not the desired outcome for a front page. This wiki suggests several workarounds to that default behavior, essentially removing the "No front page content has been created yet" message:
You can create a page, say a basic page content type, call it "My Default Homepage" then go to ../admin/config/system/site-information and set that page as Default frontpage. This is what rickumali suggests. Most users then want to remove the page-title which leaves them with yet another problem.
You can use one of the many modules that provide a solution: Front, Empty Page, Empty Front Page and I'm sure there are a few others if you search for it.
You can use the Front Page view that ships with the views module to create a query listing content, display it on a page, give that page a path, and set that path to be the default frontpage. Basically this is what ahhao describes.
And then there are the theme layer coding solutions. dquark3's solution changing a few lines in your theme's page.tpl.php, MahmoudMostafa's solution to use a preprocess function added in template.php, and vande's solution to use an other page altogether. You then still have to create content for the homepage. :)
And, finally, you can use custom css, such as by installing http://drupal.org/project/css_injector. The unwanted message is styled with the id #first-time. So, adding the following in CSS Injector to the <front> page only will remove the message: #first-time{ display: none; }.
All in all this underlines one of the difficulties for novice Drupal users, there are numerous solutions to a problem, and you have to know what Drupal presumes.
(This is an edited version of Argus's summary of a Drupal Support:Post Installation forum question. Thanks Argus for your fantastic summary of a rather long-winded discussion! I went with the front page view method myself.)
And easier solution is to unset or to empty the proper theme variable either in hook_preprocess_page or in page.tpl.php
In hook_preprocess_page() ...
<?php
if($variables['is_front']){
$variables['title'] = ''; // This is optional ... it removes the default Welcome to @site-name
$variables['page']['content']['system_main']['default_message'] = array(); // This will remove the 'No front page content has been created yet.'
}
?>In page.tpl.php, put the following somewhere below the big commented section at the beginning of the file ...
<?php
if($is_front){
$title = ''; // This is optional ... it removes the default Welcome to @site-name
$page['content']['system_main']['default_message'] = array(); // This will remove the 'No front page content has been created yet.'
}
?>Note that to avoid strange errors, an empty array was used for what used to be an array() and an empty string for what used to be a string variable.
(if you find this wiki to be lacking or outdated we apologize and encourage you to contribute your own knowledge and research to the wiki)
Comments
There needs to be an easy fix
There needs to be an easy fix for this. Many people use rotors and context and everything else to build pages.
There is an easy fix.
Added the easy fix. Unable to delete this comment.
Easy fix by module
https://drupal.org/project/empty_front_page
<?phpfunction
You can put this in the template.php file for the easiest method of getting it in your theme.
<?phpfunction hook_preprocess_page(&$variables) {
unset($variables['page']['content']['system_main']['default_message']);
if(drupal_is_front_page()) {
drupal_set_title('');
return array();
}
}
?>
Jan
It's strange, there is content added on the front page. My homepage exist only out of blocks. D8 still render the message that there is no content on the front page. When I add ( as trial) a node that was promoted to the FrontPage, the message indeed disappeared. I finally could remove it by adding a CSS class :
'views-element-container {display: none;}' Found the class after viewing the source. Hope this may help.
Module Empty Front Page works fine (D7)
Hi guys,
I would like to concur with previous comments, suggesting the module Empty Front Page as a potential solution for this ticket.
D7: The module is very clean, simple, lightweight and contains a single hook:
hook_menu_alter. It overrides the path'node''s page callback'page callback'which returns an empty array.Just enable the module (flush the cache if necessary) and the
No front page content...should have disappeared.D8: Project' page has some information about the D8 module, but I didn't have any chance to test it yet.
Would be glad to hear some feedback from anybody who's tested/worked with the D8 version.
Thanks very much to everyone for your testing, reporting, feedback and involvement in the Drupal community.
Cheers!