Introduction to Drupal 8 theming - cover all the bases of the new D8 theming system with Twig
Drupal Camp Asheville 2021 Online Edition - July 8th-9th
Introduction to theming for Drupal 8.
We'll create a new Drupal 8 theme using Bootstrap built as a child-theme atop the core theme 'Stable'.
We'll show how to add Bootstrap downloaded right from getbootstrap.com as a library theme dependency in your D8 theme.
Bootstrap is used as an example, but you can user your (micro)framework of choice - e.g. Foundation, bourbon/neat etc. Nothing is Bootstrap specific, we are using it as a well known example.
How to correctly configure D8 for twig/theme debugging. There is a lot of terrible information out there.
Show how to set up theme debugging correctly (no more $drush cr, $drush cr):
- Theme debugging comments in the source
- Disable page caching
Additionally, we'll cover:
- How to work out what templates to use.
- How to work out what preprocess functions to use.
- Define your own regions.
- Define your own js libraries, and only load the js on the pages it's needed - not every page.
- How theme libraries work in D8.
We'll do a quick twig demo, looking at:
- Filters and control structures
- Discuss finding the available template variables
- How to add new ones and pass them to Twig
- Available preprocessor hooks
- And more!