Site Building

13.7. Updating a Theme for Drupal 8, 9, 10, and 11

Goal

Update a contributed theme on your site and run the Database Updates script.

Site prerequisites

Steps

Sprout Video

Updating a contributed theme requires first putting your site into maintenance mode, then obtaining the new code files and applying any required database updates, then finally taking the site out of maintenance mode.

You can update the code for a contributed theme using Composer. If you are updating a custom theme rather than a contributed theme, obtain the new theme files, then continue with instructions for running the database updates via the administrative interface below.

This assumes that you are using Composer to manage the files in your site; see Section 3.5, “Using Composer to Download and Update Files”.

Update a contributed theme with Composer

  1. Put your site in maintenance mode. See Section 11.2, “Enabling and Disabling Maintenance Mode”.
  2. In the Manage administrative menu, navigate to Reports > Available updates > Update (admin/reports/updates).
  3. Find any themes in the list that need updating.

Image
Available updates

  1. Determine the short name of the project you want to update. For contributed modules and themes, it is the last part of the URL of the project page; for example, the Honey theme, at https://www.drupal.org/project/honey, has short name honey.
  2. If you want to update to the latest stable release, use the following command, substituting the short name of the project to be updated for honey:

    composer update drupal/honey --with-dependencies

+ To learn how to download specific versions see Section 3.5, “Using Composer to Download and Update Files”.

  1. After obtaining the new theme files run any database updates page by typing the URL example.com/update.php in your browser.
  2. Click Continue to run the updates. The database update scripts will be executed.
  3. Click Administration pages to return to the administration section of your site.
  4. Take your site out of maintenance mode. See Section 11.2, “Enabling and Disabling Maintenance Mode”.
  5. Clear the Drupal cache (refer to Section 12.2, “Clearing the Cache”).

Expand your understanding

Drupal User Guide