Theming Drupal

Theming guide for Drupal. You can browse contributed themes or build a custom theme for your site.

Defining a theme with an .info.yml file

Define a Drupal theme with an .info.yml file.

Drupal theme folder structure

A theme is a collection of files that define the presentation layer. You can also create one or more "sub-themes" or variations on a theme.

Adding Regions to a Theme

What is required to add regions to a theme

Adding assets (CSS, JS) to a Drupal theme via *.libraries.yml

In Drupal, stylesheets (CSS) and JavaScript (JS) are loaded through the same system for modules (code) and themes, for everything: asset.

Twig in Drupal

Twig is the default template engine for Drupal.

Creating sub-themes

Sub-themes are just like any other theme, with one difference: They inherit the parent theme's resources. There are no limits on the

Sub-theming: Using Stable/Stable 9 as a base theme

Themes may extend the Stable themes to ensure their generated markup is not changed by Drupal updates.

Classy themes css selectors

Document all css class selectors that are in the classy theme Drupal8 RC 2

Including Default Image Styles With Your Theme

Drupal has a powerful image manipulation system that allows for the creation of image styles that can perform various effects on an image

Including Part Template

Many themers prefer to keep header / footer codes in a separate file and call the file in page.html.twig

Using attributes in templates

Attribute objects are used in Twig templates to pass in variables like CSS classes, storing sets of HTML attributes and providing methods

Preprocessing and modifying attributes in a .theme file

You can affect output of certain HTML via preprocess functions. For example, if you wanted to add a class to a menu

Working with breakpoints in Drupal

The Breakpoints module standardizes the use of breakpoints and enables modules and themes to expose or use each others’ breakpoints.

Creating advanced theme settings

In the Drupal administration section, each theme has its own settings page at admin/appearance/settings/themeName. And this page has a form

Theming differences between Drupal 6, 7, 8, 9 & 10

This is a list of some of the most noteworthy changes in Drupal 8 that affect theming.

Upgrading classes on 7.x themes to Drupal 8 or later

Changes to core classes

Drupal Twig conversion instructions (tpl.php to html.twig)

This document was used during much of the Twig conversion process for Drupal 8 and could be useful to you too for updating your own themes

Creating automation tools for custom themes (Gulpjs)

Using automation tools simplifies the task of creating themes. Here we are going to use gulpjs to create an automation tool for a custom

Sub-Theme inheritance

Which properties of a base theme do and don't get inherited by a sub-theme.

Update the throbber

Update the spinning blue wheel in the right side of ajax forms with a little CSS.

Using Single Directory Components

Single Directory Components (SDC) are Drupal's implementation of reusable HTML, CSS, and JavaScript UI components.

Z-indexes in Drupal 8+

A table showing all elements with z-indexes in Drupal 8 core themes, modules and libraries.

Guide maintainers

joelpittet's picture
Amber Himes Matz's picture