0

After enabling Layout builder for Page content. I can see in Manage fields, a new field called layout_builder__layout. I want to print this inside node--page twig template. This should work but it does not. {{ content.layout_builder__layout }}. Printing all the content does display it like this {{ content }} How can I print only the layout builder?

1 Answer 1

1

Layout builder and Manage fields (moving fields inside Manage Display) are mutually exclusive, you use either the first or the second, you can not mix them. As soon as you activate Layout Builder for a node type, the entire Twig render array is only the Layout builder.

So just render {{ content }}, which renders its one and only child {{ content._layout_builder }}

4
  • Thank you @hudri Jun 27, 2021 at 13:46
  • @hudri suppose I have enabled layout builder for a content type but one one particular node I want to do something different - so I can no longer use {{ content.body }} in the node's twig template ie it renders nothing?
    – Juc1
    Sep 9, 2022 at 11:10
  • No you can't. You could create a node--NUMERIC_ID.html.twig overwrite template, and use manually, hard-coded twig in that template to render your fields, e.g. <div class="my_class">{{ node.field_XXX.0.value }}</div> etc.
    – Hudri
    Sep 9, 2022 at 12:53
  • In order to print just a Node field somewhere on the page you can also use the fieldblock module. Aug 20, 2023 at 16:05

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.