X
    Categories: Drupal Tutorials, Tips and Guides

Install A Drupal Bootstrap Theme Using Composer

In a previous tutorial, I have already covered the process of creating a Drupal 8 Bootstrap theme. While installing a theme through the Admin UI is pretty simple, installing it via Composer requires a bit of work. In this guide, I will show you how to install a Drupal Bootstrap Theme using Composer.

First Things First!

Before getting started, one important thing to understand is that not every Drupal package is available via composer.JSON right out of the box. Hence if you try to install the theme via the command composer require drupal/bootstrap or composer require twbs/bootstrap before making appropriate changes to the composer.JSON file, the theme won’t appear in the Admin UI.

Add Appropriate Repositories

So what you need to do now is to add the appropriate Drupal repositories to the composer.JSON file. You need to look for a package name for Bootstrap for Drupal, here. After finding out the package name, simply edit the composer.JSON file using your text editor. Add the following lines before the line starting with “extra”:

"repositories": { "drupal": { "type": "composer", "url": "https://packages.drupal.org/8" } }

Make Appropriate Changes via Composer

Now, if you previously tried adding the theme via the composer require twbs/bootstrap command, you must first remove it first. You can do this by executing the following command:

composer remove twbs/bootstrap

Now, run the following command to install the theme successfully on your Drupal site:

composer require drupal/bootstrap

Conclusion

That’s it! You’ve successfully installed the Drupal Bootstrap Theme using Composer. The only problem that might pop up is that Composer doesn’t include the required repositories by default. Hopefully, these will be added in the future releases. Until then, you can follow this guide in order to install any module or theme that has a repository for Composer.

Hamza Zia: Hamza is a Drupal Community Manager at Cloudways - A Managed Drupal Hosting Platform. He loves to write about Drupal and related topics. During his free time, he can be seen obsessing over Football, Cars, Android and Gaming.