Drupal developers and interface engineers do not always create custom themes from scratch. Sometimes, we are asked to create starter themes that we begin any project from or subthemes that extend the functionality of a base theme. Having the knowledge of how to handle each of these situations is important, and in this chapter, we will be learning it as we cover the following:
*.info.yml
file, and allow us to work with a *.libraries.yml
file to manage both CSS and JS assets. Our starter theme will involve multiple techniques that are common to any theme, including integrating a CSS framework such as Twitter Bootstrap.While we work through each section, we have the ability to refer back to the Chapter04
exercise files folder. Each folder contains a start
folder and an end
folder with files that we can use to compare our work when needed. This also includes database snapshots that allow us to start from the same point when working through various lessons. Information on how to restore database snapshots is covered in Chapter 1, Setting Up Our Development Environment.
Whenever we begin developing in Drupal, it is preferable to have a collection of commonly used functions and libraries that we can reuse. Being able to have a consistent starting point when creating multiple themes means that we don't have to rethink much from design to design. This concept of a starter theme makes this possible, and we will walk through the steps involved in creating one.
Before we begin, take a moment to browse the Chapter04/start
folder and use the drupal8.sql
file to restore our current Drupal instance. This file will add additional content and configuration needed while creating a starter theme. Once the restore is complete, our homepage should look like the following image:
This is a pretty bland-looking homepage with no real styling or layout. So, one thing to keep in mind when first creating a starter theme is how do we want our content to look? Do we want our starter theme to include another CSS framework or do we want to create our own from scratch?
Since this is our first starter theme, we should not be worried about recreating the wheel but instead should leverage an existing CSS framework such as Twitter Bootstrap.