Just tried the new core modules Layout Discovery and Field Layout and I want to render the title of a node between two fields. Without these modules, node's title can be rendered between other fields very simple by using inside node.twig.html something like:

{{ content.field_image }}
{{ label }}
{{ content.body }}

But when I try to use {{ label }} inside the registered layout template, nothing gets rendered. Can somebody help me?

Thank you in advance.

1 Answer 1


I wasn't able to get variables inside layouts due to this bug https://www.drupal.org/project/drupal/issues/2861840 Drupal 8.5 fixed the problem. Now, inside mytheme.theme if I put this:

function MYTHEME_preprocess_layout(&$variables) {
  $request     = \Drupal::request();
  $route_match = \Drupal::routeMatch();
  $title       = \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject());
   $variables['node_title'] = $title;

I'm able to use {{ node_title }} inside layouts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.