Remove "No front page content has been created yet" 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(&amp;$vars) {

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

    unset($vars['page']['content']['system_main']['default_message']);
  } 
}
There are many possible solutions for this problem, but here are a few of the more straightforward ones:


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)


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.


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-&gt;id() == 'frontpage' &amp;&amp; $view-&gt;current_display == 'page_1') {
    // Use some or all of the following 3 lines to remove specific
    // 'no results' behaviors
    unset($view-&gt;empty['area_text_custom']);
    unset($view-&gt;empty['node_listing_empty']);
    unset($view-&gt;empty['title']);
  }
}


or you could use $view-&gt;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.