New to Drupal (using drupal 8) .. please bear with me.. I 've tried to find an answer, but I couldn't...

I have created a content type, say 'course' that holds info about a particular course. I have successfully created and placed a twig template, node--course.html.twig and through there I can control the layout of all dynamically created courses.

So far so good .. However, that course is linked to a simple taxonomy (entity reference) which has only two terms, say 'theoretical' and 'classical'. Say that this value is held within field_course_direction.

Now the problem .. When I output any course I use my node--course.html.twig and somewhere I have something like:

Direction: {{ content.field_course_direction }}

So I get the appropriate value (say 'classical') as a link, which points to a view of all courses under 'classical'.

The problem is - that page which is something like 'my-site.com/taxonomy/term/37' for me, again uses the node--course.html.twig template, and as a result comes up really weird with some HTML stuff I dont want there.

I have enabled twig debug, and in the HTML source I indeed see the 'X' next to the template .. But why is that happening? What does this have to do with my 'course' content type? Why is that template being picked up? Is it because of the relationship between them? ...

I 'm quite confused .. Obviously I haven't understood how templates should be named and used, but still I can't get why that view has anything to do with a specific template such as node--MY_CONTENT_TYPE.html.twig ....

Thanks a lot for your patience and time ..

PS - I could replace my code with something like:

Direction: {{ node.field_course_direction.entity.label }} 

and thus get only the 'raw' value, in this case a simple string saying 'Classical' without the link, but this is not what I want/ask .. I ask why is that template being picked up by a page that seems completely irrelevant to me ...

1 Answer 1


A view can show content or fields. The taxonomy term view shows content and this means it renders each node in a node template. If you don't want that the template of the full node display is picked up by the view use different view modes, which you can append to the template name:

node--course--full.html twig

teaser is the view mode the taxonomy term view uses by default. You can change this to a custom view mode if you want to style the nodes displayed here in a different way than in the front page view which uses teaser as well.

  • Thanks - After searching around I did something like: {% if teaser == true %} which I left empty at the top and then an {% else %} where I keep my twig layout which I want for full display. It works .. But I kinda feel this is not exactly the best way to do it ... I don't have a good grasp of how all this works .. Need to find better documentation. A lot of twig documentation, but not much regarding drupal and twig. Hard for a newbie like me to figure out both at the same time. Thanks for your input, I 'll keep this open for a bit in case someone else contributes something..
    – thomas
    Feb 17, 2018 at 18:09
  • Yes, but with your first approach, looking for the right template name (what your question was about), you only need to add --full to the template name and get the same result.
    – 4uk4
    Feb 17, 2018 at 19:03
  • @thomas You asked why the node template was used for a taxonomy term page, and that is answered here. It also suggests how to have a template file that is used for the taxonomy term page, and one for the node page. Probably the piece you are missing is that a taxonomy term page is a list of nodes using that taxonomy term. That is why a node template is used for a taxonomy term page.
    – apaderno
    Feb 17, 2018 at 21:42
  • Ok thanks guys ... I 'm trying to get my head around all this, it's a bit overwhelming at the beginning. I do try to read and research a lot before asking here .. The thing you mentioned at the end: 'list of nodes using that taxonomy term' is very useful, I had not understand this.
    – thomas
    Feb 17, 2018 at 22:35

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.