Bootstrap is a popular web development framework developed by Twitter and available under MIT License. You can use it to build the theme for your Drupal 8 website.
The Bootstrap toolkit has everything you’d need to build a web page including shortcodes for CSS, breadcrumbs templates, tooltips, and navbars.
For Drupal 8, you’d have to use the Bootstrap module which implements Bootstrap 3 framework. If you’re using CDN, it will download the necessary files from the jsDelivr CDN when loadingthe web pages.
In this tutorial, learn how to install and start using the Bootstrap module for your Drupal 8 website.
Once downloaded, upload it to admin/theme/install. Then navigate into admin/appearance. Here, you’ll now see Bootstrap listed. Set it to default.
Also review the CDN settings. By default, it will be set to jsDelivr. But if you want to deliver the files locally, then set it to “none”.
For the sub-theme, you’ll have three options, which are:
Once you’ve chosen the one to proceed with, copy the files from the “themes/bootstrap/starterkits” directory. Then create a folder and paste them there. This is your sub-theme folder. Provide a name for the folder of your choice.
If you want to edit the sub-theme files, you need to locate the following files in the sub-directory:
You have to replace THEMENAME with the name of the folder you just created.
Then, open the files and replace THEMENAME with the name of the sub-theme folder. If you want, you can also change the name, description, and values present in the subtheme variables.
Then, make changes the name of the following:
Once you’re done replacing the variables in the sub-theme package, go to “admin/appearance” and make the sub-theme folder as default.
Install Bootstrap Layouts Module
The next step is to install Bootstrap Layouts module. It can improve the template selection in Drupal.
You can download it from Drupal Module library. Once downloaded, navigate into admin/structure/types/manage/*/display. Here, you can select the layout for the content types. Select “Bootstrap” and one of the display options from the menu.
For configuring Bootstrap Templates module, follow these steps:
For container element, add this code:
Or
For Jumbotron, add:
For buttons, add:
For labels, add:
For badges, add:
Similarly, find shortcodes for other elements and add to your files wherever necessary.
So that’s how you can use Bootstrap along with your Drupal 8 website. For more assistance, contact the hosting support team.
The Bootstrap toolkit has everything you’d need to build a web page including shortcodes for CSS, breadcrumbs templates, tooltips, and navbars.
For Drupal 8, you’d have to use the Bootstrap module which implements Bootstrap 3 framework. If you’re using CDN, it will download the necessary files from the jsDelivr CDN when loadingthe web pages.
In this tutorial, learn how to install and start using the Bootstrap module for your Drupal 8 website.
- Install and Enable Bootstrap Theme
Once downloaded, upload it to admin/theme/install. Then navigate into admin/appearance. Here, you’ll now see Bootstrap listed. Set it to default.
- Configure Theme Settings
Also review the CDN settings. By default, it will be set to jsDelivr. But if you want to deliver the files locally, then set it to “none”.
- Create a Drupal Sub-theme
For the sub-theme, you’ll have three options, which are:
- CDN Starterkit
- Less Starterkit
- Sass Starterkit
If you want to edit the sub-theme files, you need to locate the following files in the sub-directory:
- /THEMENAME/THEMENAME.info.yml.
- /THEMENAME/THEMENAME.starterkit.yml
- /THEMENAME/THEMENAME.libraries.yml
- /THEMENAME/THEMENAME.theme
- /THEMENAME/config/install/THEMENAME.settings.yml
- /THEMENAME/config/schema/THEMENAME.schema.yml
Then, open the files and replace THEMENAME with the name of the sub-theme folder. If you want, you can also change the name, description, and values present in the subtheme variables.
Then, make changes the name of the following:
- Library extension: THEMENAME/framework
- Sub-theme configuration: /THEMENAME/config/schema/THEMENAME.schema.yml
- THEMENAME.settings and THEMETITLE settings
Install Bootstrap Layouts Module
The next step is to install Bootstrap Layouts module. It can improve the template selection in Drupal.
You can download it from Drupal Module library. Once downloaded, navigate into admin/structure/types/manage/*/display. Here, you can select the layout for the content types. Select “Bootstrap” and one of the display options from the menu.
For configuring Bootstrap Templates module, follow these steps:
- Navigate to display configuration page for a particular content type
- In the layout settings, select “Three colum stacked”
- Then open the modules/bootstrap_layouts/bs-3col-stacked folder
- Find the template file that’s created by the module and download it
- Copy the bs-3col-stacked to the sub-theme folder to override it
- Make necessary changes to the template file to create a custom design
- Add CSS Shortcodes for Custom Page Styles
For container element, add this code:
Code:
<div class="container">
<!-- Content here -->
</div>
Code:
<div class="container-fluid">
<!-- Content here -->
</div>
Code:
<div class="jumbotron">
<h1>Headline Text - Large Type</h1>
<p>Lorem ipsum dolor sit amet.</p>
</div>
Code:
<p>
<button type="button" class="btn btn-default">Default</button>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-link">Link</button>
</p>
Code:
<p>
<span class="label label-default">Default</span>
<span class="label label-primary">Primary</span>
<span class="label label-success">Success</span>
<span class="label label-info">Info</span>
<span class="label label-warning">Warning</span>
<span class="label label-danger">Danger</span>
</p>
Code:
<p>
<a href="#">My Profile <span class="badge">42</span></a>
</p>
So that’s how you can use Bootstrap along with your Drupal 8 website. For more assistance, contact the hosting support team.