Week 7: Learn about Preprocess Functions

This is Week 7 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 preprocess functions and how to utilize them in a Drupal theme. Go through each tutorial and then apply what you've learned in the final hands-on exercise. After you complete the last tutorial listed (Exercise: Preprocess Functions), return to Hands-On: Theming for recommended next steps in the section, "Continue your theming journey".


  1. Understand the concept of preprocess functions
  2. Understand what kinds of functions and logic you can put in a .theme file
  3. Understand the concept of theme hook suggestions
  4. Understand how you can discover, add, or alter theme hook suggestions
  5. Be able to complete Exercise: Preprocess Functions in which you will:
    • Define a function that implements a preprocess hook
    • Define a new variable using PHP and make it available for use within a specific template file

Sign-up for weekly email reminders

Sign-up for the Hands-On Theming email list and get reminders and tips about each week's exercises!


Own this course

You can also purchase the Practical Drupal Theming course on Thinkific. The course material is the same, but you can access the content without a Drupalize.Me membership and you will own the course forever.