A Drupal 8 Festivus

In the spirit of Festivus some members of our team attempted a Drupal 8 feat of strength to ensure we were able to thoroughly air our grievances about the theme layer in Drupal 8.

Several of our front end developers accepted the challenge to build a simple two-page Drupal 8 theme based off of an older project's design.

Below are the areas that most confused them or slowed them down, or tripped them up during the process. I hope you can take advantage of our collected wisdom to smooth out your own first experience with building a theme in 8.

DPM doesn't work?

Your old friend dpm() isn't currently working in the latest version of Devel module for Drupal 8. Luckily we have a new alternative that provides some slick functionality beyond what we were used to in dpm(). Kint is currently working as expected and provides much better styling for objects and extra tidbits of info about available methods. Just replace your calls to dpm() with kint() and you're good to go.

Say goodbye to drupal_add_css().

There is a new game in town when it comes to controlling what CSS and Javascript get added to your Drupal site. With the addition of themename.libraries.yml file we can define new libraries, conditionally load libraries when we need them and declare dependencies between libraries. The change may be confusing at first, but ultimately a huge boon for front end performance and theme organization.

Where did my variable go?

If you aren't a module developer the new config system in Drupal 8 may not have crossed your radar yet, but that doesn't mean we will be able to avoid it entirely in the theme layer. Setting a variable is no longer a one step process you can accomplish from Drush. You will need to load your value from its config object and set it on the appropriate object. You can learn more about the new configuration system in Alex's series about it.

Overall everyone was excited about the improvements provided and the theme layer seems very stable and ready to be stress tested. Spin up your own Drupal 8 theme and let us know what trips you up.