Drupal 8 module: Duplicate title in twig custom node template

Written by Arvind

So, you have a module, and created twig template named node–[type].html.twig, Then when you go and visited node template page, the title is duplicated!

Node page duplicate title

You went added it in blocks or in layout builder added the node, still duplicated. How do we fix this issue? Just remove the title/label in your custom template node–[type].html.twig.

{{ title_prefix }}
{% if label %}
  <h2{{ title_attributes }} class="block-title">
    {{ label }}
  </h2>
{% endif %}
{{ title_suffix }}

Why?

There are 3 items that could be involve on this.

The First one is in the blocks under main region, there is Page Title block.

Page title.

This is part of the core, and it needs to be added in the main region.

The Second one is “Display title” under block configuration.

Block title.

When adding block. there’s an option if you want to display the title or override the block title.

The Third one is another “Display title” under layout build.

Block title.

This is the same option we see in configure block.

I hope this one helps you. Chow!