Main Content

Don't fear templates! Using Twig templates with Nodes, Views, and the new Layout Initiative

October 26 1:30 PM-2:15 PM

Watch the session video here.

Even today, with Twig templates in Drupal 8, it's common to see sites being made with some of the hacks to avoid writing templates (I'm looking at you hidden Views fields being used in a psudotemplate) and people using a wide range of modules that often do nothing but add a small amount of static HTML to node output (social sharing, social commenting, third party integrations in general), or layout tools that essentially just shift the hassle of writing templates to the hassle of themeing extremely generic output. 

While the array of layout tools at our disposal today have their place, they don't replace the need for simple templates. I'll go over some common use cases where Twig templates are an easy and efficient solution including: site hero/banner images, social sharing, Views output, and nested Paragraphs. How to create and add new template files, and I'll also touch on the new Layout Initive.

TL;DR

Topics:

  • How to know what to name template files and how to add new template suggestions.
  • Writing simple Node templates
  • Views templates that output either one item per row, or three items per row.
  • Creating a simple gallery widget with nested Paragraphs and Twig templates.

 

Login to Register