Drupal - How do I remove page title/header?

Drupal 8 places the page title in its own block (called Page title). You can control when and where that block displays on the block layout page: /admin/structure/block


You can do this entirely with CSS. You need to target that node which you are using as HOME page.

Now, Drupal-7 was generating specific class for each node. And this way it was easy to target each individual node and we were able to apply the specific CSS to that particular node.

But, in Drupal 8 this property is not available, hence we need to add this. follow following steps. I am showing this using Bartik theme as I do not have familiarity with Bootstrap theme. You can do with bootstrap theme also. It is pure CSS, so no sub-theming necessary.

1. Add the function to bartik.theme file.

if ($node = \Drupal::request()->attributes->get('node')) {
    $variables['attributes']['class'][] = 'page-node-' . $node->id();
  }

in the section of,

function bartik_preprocess_html(&$variables) {   

}

Why I am showing this way, because there is already other codes in function bartik_preprocess_html(&$variables), so add this function as last line.

Clear cache,

2. Get the CSS for that node

Now, if you do Inspect element on that particular node. You can find the class in <body></body> section as page-node-XX.

3. Go to core/themes/bartik/css/components/page-title.css, and add following code in that,

.page-node-XX .page-title {
 display: none;
}

Clear cache,

Now, this way you can target that particular node and you can do whatever CSS you want to apply.

Credit for function code: Link


you can also use this module for drupal 8 https://www.drupal.org/project/exclude_node_title

  • This module handles a very simple functionality, decide whatever to exclude a node title from full node page or node teasers. It provides a checkbox on node-edit pages for easier exclusion. Also provides the option to hide all titles of a certain Content type. From the administrative interface you can select a content type to hide title for.

Tags:

Theming

8