This is Week 6 of the 7-week course Hands-On: Theming. Get started with Drupal 8 theming in 1 hour a week for 7 weeks. Based on our popular Drupal 8 Theming Workshop featured at DrupalCon.
Time to complete: About 1 hour
This week you will learn about the basics of Twig and how it is used in a Drupal theme's template files. Go through each tutorial and then take the opportunity to practice overriding templates and using Twig in the exercises. You will only need to know the basics of Twig to complete the exercises, so don't spend too much time on any one tutorial. (You can always reference Twig Syntax Delimiters or Twig Filters and Functions as you work through the final exercise.) Be sure to all exercises before you move on to Week 7: Preprocess Functions.
- Complete Exercise: Override the Node Template
- Complete Exercise: Override the Main Menu Template
- Complete Exercise: Override the Image Field Template
- Complete Exercise: Use the t Filter in a Template
In these exercises you will:
- Get comfortable with the process of overriding template files
- Utilize various methods for adding CSS classes in templates
- Use common filters like