This tutorial will show you how to manage themes in Drupal.
Proudly Sponsored by FastDot International Cloud Hosting.
Visit our website for more web-hosting tutorials:
http://www.fastdot.com
Cloud VPS Hosting | cPanel Web Hosting | Domains
Managing themes in Drupal involves installing, enabling, customising, and managing the appearance of your Drupal site. Here is a step-by-step guide to help you effectively manage themes in Drupal:
1. Understand Drupal Themes
Drupal themes control the visual appearance of your site, including layout, colours, and fonts. There are two main types of themes:
- Core themes: Built-in themes that come with Drupal.
- Contributed themes: Themes developed by the community and available on the Drupal theme repository.
- Custom themes: Themes created specifically for your project.
2. Finding and Downloading Themes
You can find contributed themes on the Drupal.org website. Look for a theme that matches your requirements.
- Go to the Drupal Themes directory.
- Use filters to find a theme compatible with your Drupal version.
- Download the theme’s
.tar.gz
or.zip
file.
3. Installing a Theme
There are two ways to install a theme in Drupal: manually or using Composer.
Manual Installation
- Download the theme from Drupal.org.
- Extract the theme files into the
themes
directory in your Drupal installation:- For site-wide themes:
/themes
- For custom site-specific themes:
/sites/all/themes
or/sites/default/themes
- For site-wide themes:
- Go to the Appearance section in the admin menu and enable the theme.
Using Composer
If you are managing your site with Composer:
- Run the following command to download and install the theme:
- Go to the Appearance section and enable the theme.
4. Enabling a Theme
- Log in to your Drupal admin dashboard.
- Navigate to Appearance (admin/appearance).
- Find the theme you installed in the list.
- Click Enable and set as default to make it the active theme for your site.
5. Customising a Theme
Drupal allows you to customise themes to match your design needs.
Using the UI
- Navigate to Appearance and click Settings for the active theme.
- Modify options like logo, favicon, colour scheme, and layout.
- Save changes.
Custom CSS
- Create a sub-theme of the parent theme and override styles using your own
styles.css
file. - Add custom styles to the theme’s CSS directory and declare them in the
theme.info.yml
file.
6. Managing Sub-Themes
Sub-themes inherit styles and functionality from a parent theme but allow further customisation. To create a sub-theme:
- Create a new directory in the
themes
folder. - Add a
theme.info.yml
file specifying the parent theme. - Override templates and CSS as needed.
7. Updating Themes
To keep your site secure and functional, ensure your themes are up to date.
- Use Composer to update themes:
- Manually download and replace files if using the manual installation method.
8. Uninstalling a Theme
- Navigate to Appearance in the admin dashboard.
- Disable the theme by switching to another default theme.
- Click Uninstall next to the theme you want to remove.
9. Using Multiple Themes
Drupal allows you to use multiple themes for different purposes, such as an admin theme and a front-end theme. To set an admin theme:
- Go to Configuration > Development > Performance > Theme settings.
- Select a theme for admin use.
10. Debugging and Managing Templates
To customise theme templates:
- Enable theme debugging in
services.yml
. - Modify
.twig
template files in your theme directory to change the appearance of specific elements.
By following these steps, you can effectively manage and customise themes in Drupal to create a visually appealing and functional website.