How can I remove default system message like "No front page content has been created yet" in Drupal 8?

I've tried below method but is doesn't work.

function MYTHEME_preprocess_page(&$vars) {

  // Remove the "No front page content has been created yet.".
  if (isset($vars['page']['content']['system_main']['default_message'])) {


2 Answers 2


There are many possible solutions for this problem, but here are a few of the more straightforward ones:

  1. Edit the Frontpage view at /admin/structure/views/view/frontpage as follows:

This View form allows you to adjust the out-of-the-box front page. In the NO RESULTS BEHAVIOR section, click on the Global: Unfiltered text item. This will open a dialog box to edit that setting. From here you can see that this is where the undesirable message is coming from. Click on the Remove link beside the bottom buttons to remove that message. Depending on the desired front page behavior, you may also want to remove one or both of the other items listed under NO RESULTS BEHAVIOR.

Once you've removed the unwanted items, be sure to click the Save button on the View form to make those changes permanent. You can then browse to the front page and see the results. (You might need to Clear all caches at /admin/config/development/performance to see the change)

  1. Or, create a custom front page:

Create new content of type Basic Page. Give it the title you want your front page to have. For the body, you can leave it blank, or put whatever static content you want to always appear on the front page. After saving and publishing this new content, write down the "/node/some-number" part of the URL.

You can now set this new node as the front page at /admin/config/system/site-information by changing the Default front page setting to the /node/some-number you wrote down earlier. Save the settings and things should be all set.

  1. To do it programmatically, you might add this code to your custom theme or module

use Drupal\Views\ViewExecutable;

// Implements hook_views_pre_render().
function MY_THEME_OR_MODULE_NAME_views_pre_render(ViewExecutable $view) {
  if($view->id() == 'frontpage' && $view->current_display == 'page_1') {
    // Use some or all of the following 3 lines to remove specific
    // 'no results' behaviors

or you could use $view->empty = []; instead of the 3 separate unset()'s to remove all "no results" behaviors from the frontpage view. Note that this code assumes you haven't changed the view's name or display name from the defaults. If this is not so, the if() statement will require some tweaking.


In Drupal 8, in Structure / Views / Edit the FrontPage and in the Page Settings / no Results Behavious Section: Click to edit each item and click 'remove' (NOTE: in the "No Results Behaviour" only)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.