How can I get the field for the title of the content?

In twig I need to do this (for jssor slider) :

{% if field_titre_url_externe is not empty  %}
  {{ field_titre_url_externe }}
{% else %}
  {{ field_title }}
{% endif %}

but field_title is showing nothing, so what is the name of this?


I'm talking about the title of a node , article or content type

In my frontend, the title has the class views-field-title

See this image for more details (that's what I want to do):

enter image description here

Access the field_url_externe is not working actually... Accessing this field will solve my problem

  • The term "title field" is a generic, ambiguous term. It would help if you clarified and narrowed the scope of your question. Is this the "title" for a Node? The title of a view? Which template are you modifying and what are you doing? At the moment it's unclear to me what exactly you're trying to do. Thank you.
    – mradcliffe
    Sep 21, 2018 at 13:52

2 Answers 2


This is the correct value for the rewrite field:

{% if field_url_externe is not empty  %}
  {{ field_url_externe }}
{% else %}
  {{ title }}
{% endif %}    

You can see the available fields in the "Replace Patterns" expandable link.

enter image description here

  • This is for the plugin jssor slider, I don't think it has something to do with the theme... The twig part I'm trying to add is in the view part in backend Sep 21, 2018 at 13:49
  • Twig is part of the theming system in Drupal... Sep 21, 2018 at 14:01
  • Are you using the jssor Drupal module?, are you using a Drupal view? I am trying to understand better your implementation. Sep 21, 2018 at 14:02
  • Yes for jssor drupal module. The part with title_prefix is not working. I'm using a view in drupal backend. This my update post for more details Sep 21, 2018 at 14:13
  • 1
    It's working, I wasn't on the right page. Thanks a lot ! Sep 21, 2018 at 15:26

Is title a field you made or do you mean the node title? Node title can be printed with either {{ label }} or {{ node.getTitle() }}.

Fields that you created on the node, they are rendered out as:

{{ content.field_title }}

Which can be checked as:

{% if node.field_title_external is not empty  %}
  {{ content.field_title_external }}
{% else %}
  {{ node.getTitle() }}
{% endif %}

You can also use {{ label }} instead of {{ node.getTitle() }}.

  • It's indeed showing the external link, but the title of the node is not showing Sep 21, 2018 at 13:36
  • That seems impossible unless this is not shown in the context of a node? Title of what node exactly? Title of the node being viewed, or title of a referenced node? A different field title?
    – Kevin
    Sep 21, 2018 at 13:43
  • Title of the node articles (drupal) and some custom content type. The title of a drupal article and it's external link will be the same, but the link won't. If the external link is set, don't show drupal article title but show external link Sep 21, 2018 at 13:46
  • Ok, you are doing this from Views, which is different than the normal theming methods.
    – Kevin
    Sep 21, 2018 at 14:59

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