Lullabot: Level Up Your Twiggery

Drupal 8’s templating language, Twig, provides a powerful suite of tools that often go underutilized. Learning when and where to apply them will empower you to create more readable and DRY code, and allow themers of all experience levels to contribute in a maintainable way.

To highlight some key concepts, let us consider a simple example—wrapping the Article node’s body field in a

element. We start with this simple tweak to node--article.html.twig.