How to display an alternative text if the comments are closed for the node? in my node type template, how do I display alternate text if comments are closed for the node ?

  {% if content.comment %}
    &lt;div class="card mb-5 p-3 shadow"&gt;
      {{ content.comment }}
    &lt;/div&gt;
  {% else %}
    &lt;div class="card mb-5 p-3 shadow"&gt;
      {{ content.field_link }}
      {{ content.field_code }}
    &lt;/div&gt;
  {% endif %}


EXAMPLE


  If comments are open :
  
  {{ content.comment }}
  
  If comments are closed :
  
  TEXT
Assuming you're using the default field definitions installed by the standard profile, what you want is the status property of the comment field of the node, which is accessible in twig via node.comment.status.

{% if node.comment.status == 2 %}
   {# comments are open #}
{% elseif node.comment.status == 1 %}
   {# comments are closed &amp; visible #}
{% elseif node.comment.status == 0 %}
   {# comments are closed &amp; hidden #}
{% endif %}