We have nodes that have dozens of fields and have elected to not include the {{ content }} variable as it is tedious and looks messy having something like the following just to not print the fields. We're manually outputting each field as needed like {{ content.myfield }}.

The problem is that when the {{ content }} variable is not in a template then that node's cache does not get cleared when a user modifies the node's content and they have to contact and admin to clear the Drupal caches.

Surely there must be a way to have a node's cache cleared when it is updated and its theme template does not have the {{ content }} variable. Please help.

{{ content|without('field_blog_posts','field_breadcumb_t','field_call_to_action','field_call_to_actions_title','field_customer_support_body','field_customer_support_button_te','field_customer_support_image','field_customer_support_title','field_hero_body','field_solutions_hero_image','field_hero_link_1','field_hero_link_2','field_hero_title','field_learn_more_text','field_meta_tags','field_newsletter_signup_banner','field_newsletter_signup_banner_m','field_product_spotlight_title','field_read_more_link_text','field_section_one_category_1','field_section_one_category_2','field_section_one_sub_title','field_section_one_title','field_section_one_video','field_section_two_category_1','field_section_two_category_2','field_section_two_sub_title','field_section_two_title','field_section_twovideo','field_section_two_view_all_link','field_spotlighted_product') }}

2 Answers 2


You can simply render it into a variable and just do nothing with it:

{# rendering the content into a variable doesn't visibly render anything, but forces the cache to bubble up #}
{% set dummy = content|render %}

Install the twig tweak module (v3.x) and then use cache_metadata filter.

When using raw values from entities or render arrays it is essential to ensure that cache metadata are bubbled up.

{# Ensure content cache metadata is rendered for the display as a whole. #}
{{ content|cache_metadata }}

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.