I have created no of nodes as content type as Article in my website(techladder.in). But I am not getting the right file where I can override the content of the file.

For example, I need to display author information above the Disqus comment section.

I was able to override the node file in my theme at following path: theme/templates/content/node--article.html.twig as following:

     {%   set classes = [
        'node--type-' ~ node.bundle|clean_class,
        node.isPromoted() ? 'node--promoted',
        node.isSticky() ? 'node--sticky',
        not node.isPublished() ? 'node--unpublished',
        view_mode ? 'node--view-mode-' ~ view_mode|clean_class,   ] %} {{ attach_library('classy/node') }} <article{{ attributes.addClass(classes) }}>

      {{ title_prefix }}   {% if not page %}
        <h2{{ title_attributes }}>
          <a href="{{ url }}" rel="bookmark">{{ label }}</a>
        </h2>   {% endif %}   {{ title_suffix }}

      {% if display_submitted %}
        <footer class="comment-submitted">
          <div{{ author_attributes.addClass('node__submitted') }}>
            {% trans %}Submitted by {{ author_name }} on {{ date }}{% endtrans %}
            {{ metadata }}
        </footer>   {% endif %}

      <div{{ content_attributes.addClass('node__content') }}>
        {{ content }}   </div>

{% if teaser %} <div class="section-divider"><hr class="section-divider"></div> {% endif %}

But here, I am not able to find a file where I can override the content of the node.

Does anyone has suggestions how can I do it in Drupal 8.

1 Answer 1


content is just the render array composed of renderable elements.

If you want to break up the fields, then you need to not use {{ content }} and instead call each field where you want them:

{{ content.field_MYFIELD }}

Those fields are controlled by their field templates.

An improvement on your code would be to not check for view modes in one template, but just make each view mode a template like node--article--teaser.html.twig, node--article--full.html.twig, node--article--some-other-mode.html.twig. It will make your code cleaner.

So you'll need to debug and find what the content variable has, and just start outputting it where you want them to render in the template.

  • Thanks! It is helpful. When I am trying to render {{ content.field_CATEGORY}} it is not displaying anything on the screen. I think field_CATEGORY is not correct. Could you correct me here? Nov 28, 2018 at 15:04
  • You'll have to find the machine name in the backend or use a debugger to see what they are. Aside from that, fields need to be VISIBLE under "Manage Display" and not hidden - then they are included in the content variable.
    – Kevin
    Nov 28, 2018 at 15:06

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.