How to Use Gridsome to Build a Static Website with Bootstrap

Gridsome is a powerful and modern static website generator that enables developers to build fast and secure websites with ease. In this tutorial, I will show you how to start a Gridsome project from scratch and integrate Bootstrap to create a responsive and modern website.

Step 1: Installing Gridsome

The first step is to install Gridsome using the npm package manager. Open your terminal and run the following command:

npm install --global @gridsome/cli

This will install Gridsome globally on your system.

Step 2: Creating a New Gridsome Project

Once you have installed Gridsome, you can create a new project using the create command. Run the following command in your terminal, replacing name-of-project with your desired project name:

gridsome create name-of-project

This will create a new Gridsome project with the default starter template.

Step 3: Developing and Building the Project

To develop and preview your project, run the following command in your terminal:

gridsome develop

This will start a local development server that you can access in your web browser at http://localhost:8080.

When you're ready to build your project for production, run the following command in your terminal:

gridsome build

This will generate a static website that you can deploy to any web hosting service.

Step 4: Adding Bootstrap to Your Project

To add Bootstrap to your project, you need to install the bootstrap and bootstrap-vue npm packages. Run the following command in your terminal:

npm install bootstrap bootstrap-vue

This will install both packages in your project.

Next, open the main.js file in your project and add the following code:

import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'

import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'


This will import and configure the Bootstrap Vue components for your project.

After adding the Bootstrap Vue components to your project as shown in the previous section, you can easily use Bootstrap components in your project using Vue-style syntax. For example, you can use the b-button component to create buttons with different styles and variants, as shown in the code snippet below:

  <b-button variant="danger">Button</b-button>
  <b-button variant="success">Button</b-button>
  <b-button variant="outline-primary">Button</b-button>

By calling these components in your Vue templates, you can take advantage of Bootstrap's pre-designed UI elements and easily customize them to fit your project's needs.


In this tutorial, I have shown you how to use Gridsome to create a static website with Bootstrap. With its easy-to-use commands and powerful features, Gridsome is a great tool for building fast and responsive websites. I hope that you found this tutorial helpful and informative. Happy coding!

Subscribe to The Code Sandwiches

Sign up now to get access to the library of members-only issues.
Jamie Larson