Problem/Motivation
You may want to check if the frontpage is being displayed in html.html.twig, to alter for example the <title>
tag content.
If you try to use is_front
variable, nothing will happen, since the variable is not available. It is only available in page.html.twig:
$ grep -liR "is_front" ./core | grep twig
./core/themes/stable9/templates/layout/page.html.twig
./core/themes/starterkit_theme/templates/layout/page.html.twig
./core/themes/olivero/templates/layout/page.html.twig
./core/themes/claro/templates/page.html.twig
./core/profiles/demo_umami/themes/umami/templates/layout/page.html.twig
./core/modules/system/templates/page.html.twig
PS: I found out later that altering the <title>
tag content is most easily done with the
Metatag โ
module.
Steps to reproduce
Try to use is_front
variable in the html.html.twig template and fail.
Proposed resolution
Add is_front
variable in the html.html.twig template.
A temporary work around is to instead check if the root_path
is empty:
{% if root_path is empty %}
This is front
{% endif %}
Taking a helicopter perspective: Would it be possible to streamline template files, to have more uniform variables sections? The available variables seem to overlap, or only be present in one (html.html.twig), and not the other(page.html.twig). Maybe they could look more like each other?
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet