Creating a custom theme to style your Drupal site
Drupal provides a theme generator to create custom themes for Drupal sites based on the Starterkit theme. This provides all of the base CSS stylesheets, JavaScript files, and Twig templates to begin customizing the look and feel of your Drupal site. The theme generator is bundled with a developer command-line tool provided by Drupal core in core/scripts/drupal
.
How to do it…
- The script for generating a theme needs to be executed in the
web
directory, so navigate there in your terminal:cd web
- Run the
generate-theme
command from thecore/scripts/drupal
script:php core/scripts/drupal generate-theme mytheme --name
"My theme"
The generate-theme
command accepts one argument – the machine name for the theme. You can also pass the name
option to give it a human-readable name.
- After the theme has been generated, it will be available in the
web/themes
directory. The command will...