Skip to: Site menu | Main content

Understanding the Drupal Way - Subthemes

In order to retain the changes you make to a theme like the Bartik theme you need to create a custom subtheme. Use the Bartik theme as a base theme.

It's beyond the scope of this post to go into detail about Drupal's theme layer and how to create custom subthemes and themes. So, I won't explain everything you have to do. You can find more information on Drupal.org.

The key point to keep in mind is that a subtheme provides a way to override (or overload if you prefer) what the base theme is doing. Drupal uses this methodology of overriding / overloading in other context as well to allow you to make changes without having to hack core.

For your convenience I have created a repository of my custom subtheme.

Place my custom subtheme inside of your sites/all/themes subdirectory. If you are using Drupal 8 you can also place it directly in the themes subdirectory. Once you have placed the subtheme in the appropriate directory enable it and set it as the default theme.

My subtheme has a page.tpl.php file inside of the templates directory that appends a literal string to the Site Title. The CSS makes the font size larger. It also targets some other things based on the example I created on my demonstration site.

If you want to learn more you can take my course "Drupal for Beginners" for just $5. You can also just watch the free preview lectures if you want to see the example of my custom subtheme in action.

Credits: XWeb | Chris Herberte | Andreas Viklund