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.
The is_front
variable was moved from _template_preprocess_default_variables()
to template_preprocess_page()
(see #2370147: Move is_front variable to template_preprocess_page()). This isn't very helpful for other theme hooks that may also be on the front page (which could be anything).
Unfortunately, this cannot yet be done until a proper "front" cache context is created in core or if core suddenly allows themes to create services (either directly or via a sub-module).
Comments
Comment #2
markhalliwellComment #4
markhalliwellThis now ensures that all templates have an
is_front
variable available (so templates that implement it don't error out).It should be noted, however, that if there is no
cache_context.url.path.is_front
service defined, the variable value will always beFALSE
.It is recommended to apply the patch in #2829588: Provide a "url.path.is_front" cache context to allow contributed themes to move global "is_front" variable back to get this variable working properly.