Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
All "meta" things are bubbled up from the various parts of the page:
- HTTP headers =>
#attached[http_header]
,#attached[html_head_link]
- HTML head:
<meta>
=>#attached[html_head]
<link>
including those to load CSS =>#attached[html_head_link]
,#attached[library]
,#attached[feed]
<script>
=>#attached[library]
The one and only exception: <title>
.
You can clearly see this is an exception by simply looking at the html.html.twig
template:
<head>
<head-placeholder token="{{ placeholder_token|raw }}">
<title>{{ head_title|safe_join(' | ') }}</title>
<css-placeholder token="{{ placeholder_token|raw }}">
<js-placeholder token="{{ placeholder_token|raw }}">
</head>
Consequently, modules that need to access the page title … can't! They have to render the entire HTML template and then parse the title out. See #2692317-10: Make everything in <head> update: <title>, <meta> tags, etc. for example.
Proposed resolution
Introduce #attached[title]
.
Merge algorithm TBD.
Remaining tasks
Discuss.
User interface changes
None.
API changes
TBD
Data model changes
TBD
Comments
Comment #2
Wim LeersComment #3
Wim LeersRelated: #2359901: Discourage $main_content['#title'] in favor of route titles and title callbacks.
Comment #4
Wim LeersComment #5
catchWe could add page title bubbling in a minor release, so moving back.
However, also postponing on #2359901: Discourage $main_content['#title'] in favor of route titles and title callbacks since Merge algorithm TBD. is where we ran into problems last time this came up, and understanding which cases aren't handled might help with that.