Updating themes to Drupal 8 #4 – Using classy as a base theme

Drupal 8’s beta version was released a few month ago and now it is time to start porting themes. In this series we are going to discuss  the most noteworthy changes in Drupal 8 about theming. Quite significant changes were introduced in the theme system between Drupal 8 and 7. This guide contains information that applies to Drupal 8 and refers sometimes to Drupal 7 in order to explain new concepts and approaches.

Classy theme

Another big change in Drupal 8 theming is the inclusion of a new theme, named Classy. But what kind of theme is it exactly? Is it a pretty new look for Drupal 8? Well, no. You will still see Bartik as the default theme on your Drupal 8 site, so why another theme? Classy is a new base theme in core, which Bartik and Seven will then use as their bases. The idea here is to provide more flexibility to themers when it comes to choosing default CSS classes. Here you have more info about the inclusion of this new theme

Sub-themes are just like any other theme, with one difference: they inherit the parent theme’s resources. There are no limits on the chaining capabilities connecting sub-themes to their parents. A sub-theme can be a child of another sub-theme, and it can be branched and organized however you see fit. This is what gives sub-themes great potential.

To create a sub-theme you define your theme like any other theme and declare the base theme using the “base theme” key. Note that the key has no underscore.

This is an example of a sub-theme that uses Classy as a base theme

name: My Theme
type: theme
description: This is an example sub theme of Classy
core: 8.x
# Defines the base theme
base theme: classy
    - css/my_theme.css
# Regions
  header: Header
  featured: Featured
  content: Content
  sidebar_first: First sidebar
  sidebar_second: Second sidebar
  footer: Footer

As you can see, the most notable difference with Drupal 7 is that the .info files have become .info.yml files that use YAML sintax

Source: Drupal.org


The most significant change to Drupal 8 theming is the introduction of the Classy Theme, which was part of Drupal 8 since its beta 2. In a nutshell, Classy is a base theme for those who want to have templates with the core classes.

This is also the base theme for the Bartik and Seven core themes. Classy’s main purpose is to store the class-enriched templates, and serve as a base theme for themes that wish to inherit them. It is not intended as a display theme, and will not contain any of its own functionality or styling. So, themers who don’t want this won’t include the “base theme” key 😛



Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s