How to Create a Node Override in Drupal 8

In Drupal development customizing the theme is an important task overall. So you want to override template for nodes, its a pretty easy job. If you familiar with Drupal 7 node overriding , you may know how to do this. Its not that different in Drupal 8 either. You need to create a custom theme before overriding the node. If you work on the Drupal built in theme, you will loose your changes when a Drupal upgrade.

Step 1

Copy core/modules/node/templates/node.html.twig file to your custom theme templates folder (ie themes/custom_theme/templates/)

Step 2

Alter the variables as per your need
For example {{ node.title.value }} will print the title of the node.
{{ node.field_youtube_id.value }} this will print a fields value in a node.

Editorial Staff
 

Editorial Staff at tutsplanet is a dedicated team to write various tutorial articles.