page-title.html.twig still show the wrapper styling.

Created on 28 November 2015, about 9 years ago
Updated 1 November 2023, over 1 year ago

Problem / Motivation

I have page-title.html.twig template in my theme D8 and is not been showing the {{ title }}. However is been displaying all wrappers around the title.

Here is my page-title.html.twig.
page-title.html.twig

{{ title_prefix }}
{% if title %}
<div class="sixteen floated page-title">
    <h2 class="title_page" {{ title_attributes }}>{{ title }}</h2>
</div>
{% endif %}
{{ title_suffix }}

Here is the output of this template page-title.html.twig.

<div class="sixteen floated page-title">
    <h2 class="title_page"></h2>
</div>

Why this is a problem ?

Because this is rendering unnecessary HTML and classes. This can affect the output of the page.

Solution

We should make sure that if we exclude the title, anything from page-title.html.twig should be remove.

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States darol100

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    Welp, there hasn't been a lot of interest in this over the years, it seems.

    It should be possible to do this same thing without adding anything to Exclude Node Title, and without any custom code, by configuring Entity Field Condition on the page title block to not show for any content types you enable Exclude Node Title on. Using this module:

    https://www.drupal.org/project/entity_field_condition β†’

    Of course, at that point, you can replace Exclude Node Title with a boolean field and be done with it.

Production build 0.71.5 2024