In Drupal, sub-themes are children that inherit the functionality and styles of a parent theme. This allows you to make customizations to the site while keeping core features and updates intact. It’s a common practice for developers to use sub-themes when they want to make changes to how a site looks without interfering with any changes or updates their peers are making. You can create one of these in Drupal by following these steps:
- Choose a Parent Theme:- First things first, you need to select a parent theme as your foundation for the site. When it comes to this you have two paths — using what’s already there or adding something new. For example, the “Bartik” theme is one that many people choose because it’s already there. If you prefer to use a contributed theme, you’ll need to download and install it.
- Create a Subtheme Directory:- Navigate to where you installed Drupal through your file browser or command line interface. Once there, create a brand new folder under the themes > custom > your sub-theme. The folder name should be all lowercase and have no spaces.
- Create a Subtheme Configuration File:- Create a configuration file in there, typically with the name mytheme.info.yml (remember to replace “mytheme” with your sub-theme’s name). With this file, you can define and specify its parent theme. This is what it should look like.
name: 'Custom theme'
type: theme
description: 'Custom sub-theme based on claro'
base theme: claro
core_version_requirement: ^9 || ^10
libraries:
- customtheme/global-styling
- Customize Your Subtheme:- Once you’ve defined your subtheme, you can start customizing it by adding CSS, templates, and other assets. To store your CSS files, make a new one called “CSS” and do the same for your template files but call this one “templates.” If you’d like to add additional CSS or JavaScript files then modify the libraries.yml file. This is what it should look like.
global-styling:
css:
theme:
css/style.css: {}
- Enabling Your Subtheme:- In the administrative interface of Drupal, go over to “Appearance.” In older versions click “Administer” then “Appearance.” Both methods will lead you to your subtheme selection. When you find it, click on the link that says “Install and set as default.” This enables it along with setting it as default for all sites.

- Clearing Cache:- Sometimes changes don’t take effect until you clear the cache. After enabling your subtheme I suggest doing this so that there are no surprises later on. Clearing the cache is simple too! Just go into configuration then performance and hit that button that says Clear all caches
Now, it’s time to move on to the subtheme. You can make changes to the subtheme, override templates, and add custom styles to get the exact look and functionality you need while still keeping the core functionality of the parent theme.
Please contact us at manish@bay20.com or call us at +91-8800519180 for any support related to Drupal. You can also visit the Drupal development page to check the services we offer.