Option 1: Is there any way to write a conditional in Twig that if field1 in Drupal is empty, I can set a default text to say "Bye"

Option 2: I was also trying to use the conditional fields module, to where field2(with the default text "Bye") will only display if field1 is empty. It doesn't seem to work though.

Any help is appreciated thank you

2 Answers 2


Solution for option-1 :

{% if node.field_example.value is empty %}
{% endif %}

Never tried with that dependency but option 2 should work, how are you setting the conditional field?

Anyway there's empty fields module that should solve your issue.

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