How to print taxonomy terms field in node templates? How can I display node taxonomy terms field in node templates of Drupal 8?

We do this in Drupal 7 by add this code to node.tpl.php file:

print render($content['field_tags']);


I tried adding the below code in Drupal 8:

{{ content.field_tags }}


but with this code have problems:


If I add some styles or make some changes to field--node--field-tags.html.twig file these changes displays in all content types also.
If I don't want to show default taxonomy terms in the bottom of article nodes (I want to move and show taxonomy terms in the top of the article) and I assign "Hidden" value in "Administration>Structure>Content types>Article" in "Format" section, this settings cause to not displays all the taxonomy terms fields in throughout of the article nodes at all.
Taxonomy terms Label always display even if no tags added to the node. How can I show taxonomy terms label and their values only when have been added any tags to it?
Yes, this will be used in all nodes with that field ! You could add a contenttype specific node.html.twig (see next point), or if you only want to add classes, do it in template_preprocess_node(&amp;$variables), add classes to $variables['content']['field_tags'][x]['attributes']['class'][] = 'my-style', you can check there for the contenttype.
What are you rendering ? If you render the node's field, you'll only get the assigned terms ?! For custom node-specific theming you could use something like this in


node--type-your_contenttype.html.twig:

   {% for item in content.field_tags %}
      {% if item['#title'] %}
        &lt;a href="{{ item['#url']}}" class="link-item"&gt;{{ item['#title']  }}&lt;/a&gt;
      {% endif %}
    {% endfor %}


Also {{ item['#options'].entity.url() }} or {{ path('entity.taxonomy_term.canonical', {'taxonomy_term': item['#options'].entity.tid}) }} could be used to retrieve the URL.



Regarding your icons

Use tid or parent and name it like icon-34. Access it in twig like: item['#options'].entity.parent or item['#options'].entity.tid.


  But I would recommend the use of a preprocess function to add a
  key-value pair to each item array where you set the name. For example
  from a field you added to your taxonomy. You could then access it in twig like {{ item.key }}