Drupal 9 provides Bartik as the frontend theme for Drupal and seven for backend, but if you need a Drupal 9 custom theme then you can create your own Drupal 9 theme development, thus improving your Drupal theming skills. The easiest way to really understand Drupal 9 theme development is to practice and create one from the ground up.
Let’s create simple theme in drupal 9 for understanding the concept of theming, then we will go in depth after basic understanding of theming concept.
Step 1. Go to your project root directory, then go to theme, and inside theme directory create custom, directory and inside custom directory create your theme name directory e.g. xyz in this case ujjivan is a theme name:
Step 2: Now, inside your theme directory create theme_name.info.yml file, in this case ujjivan.info.yml file and paste the below lines.
Name your theme
The first step in creating a theme is to choose a human-readable name for it, and a corresponding machine name. The machine name will be used as the name for files, folders, and functions in your theme, and is used by core Drupal programmatically to refer to your theme. The machine name is usually the human-readable name, converted to lower-case and with underscores instead of spaces. For example, if your theme is named “Ujjivan”, then the machine name is “ujjivan”. If your theme name is longer, like “Ujjivan Bank”, your machine name would be “ujjivan”.
There are some important rules to follow when selecting a machine name:
- It must start with a letter.
- It must contain only lower-case letters, numbers and underscores.
- It must not contain any spaces.
- It must not be longer than 50 characters.
- It must be unique. Your theme should not have the same short name as any other module, theme, theme engine, or installation profile you will be using on the site.
- It should not be any of the reserved terms (folders in the Drupal distribution): src, lib, vendor, assets, css, files, images, js, misc, templates, includes, fixtures, drupal.
name: Ujjivan type: theme description: 'This is Theme for Ujjivan Small Finance Bank' core_version_requirement: ^9 || ^10 base theme: classy package: custom version: VERSION screenshot: screenshot.png
Step 3: login into Drupal and flush the cache and go to projectroot/admin/appearance and Click on “Install and set as default“
You have successfully created and install your custom theme in drupal 9.