Creating a Custom Theme in Drupal 10 using a Starterkit Theme

By toswebdev, 26 December, 2022
Creating a Custom Theme in Drupal 10 using a Starterkit Theme

To generate a new theme named "my_new_theme" in Drupal, you can use the following command from the Drupal root directory: Ex:-  C:\wamp64\www\d10\web

php core/scripts/drupal generate-theme my_new_theme

This will create the new theme in the themes directory by default. You can use the --help flag to view all configuration options for the generate-theme command:

php core/scripts/drupal generate-theme --help

You can also use a custom starterkit theme as a starting point for your new theme. To use a theme called "source_theme_name" as a starterkit, you will need to add a line containing starterkit: true to the file, and make any necessary design decisions (such as default markup and CSS).

Then, you can generate a new theme using the starterkit theme with the following command:

php core/scripts/drupal generate-theme --starterkit source_theme_name my_new_theme

The source_theme_name theme can also include a \Drupal\source_theme_name\StarterKit class that implements the \Drupal\Core\Theme\StarterKitInterface interface, which can perform additional post-processing on the generated theme. You can refer to the core Starterkit theme for an example of this implementation.


All comments go through moderation, so your comment won't display immediately.