How I created a basic Gatsby + Bulma starter template

in #utopian-io7 years ago (edited)


gatsby.png

Repository

https://github.com/aviaryan/gatsby-bulma-default

Introduction

I recently created a project called "Gatsby Bulma Default" which is a basic Gatsby starter template that includes a fully configurable Bulma out-of-the-box. I created it because Bulma and Gatsby are being used for UI development and static website development heavily these days and so I thought it would be a good idea to mix them together.

In this post, I will go step by step on how I did it so that you don't think of this template as a black-box and can potentially create your own template if needed.

The Steps

To implement this project, I first cloned the default gatsby starter pack. It is a very basic project that shows how to use Gatsby and comes with absolutely no batteries included. In fact, if you see its dependencies list, you will see that it includes almost nothing extra.


Screen Shot 2018-06-09 at 2.18.50 PM.png
gatsby-starter-default on npm

I chose this starter template as the base because I wanted the user to have as much as flexibility as possible. Now, after that, I made changes to the project so that it is converted into a Bulma starter pack.

For that, first I had to add the bulma package.

> yarn add bulma

But adding Bulma was not enough as we also want to make the Bulma installation configurable. In other words, we need SASS/SCSS support for the project.

Luckily, this is quite easy to do in Gatsby. We just need to add and enable the SASS plugin and then it will work. So to install the plugin, I did -

> yarn add gatsby-plugin-sass

After that, we need to enable the plugin in gatsby-config.js.

carbon (1).png

That's pretty much it. Now we can include SCSS files instead of CSS files.
For example, this is the index.scss that contains all the styles now and it is inspired from the official Customize Bulma guide.

We include the SCSS file the same way we do with CSS files (with import statement).

carbon (4).png

Once this was done, I had to change the default site pages so that they can better reflect the features that Bulma has. For example, I changed the index page to use Bulma's title and subtitle classes.

carbon (2).png

I changed all the pages so that they use proper Bulma classes and then it was done. The final result can be browsed at https://aviaryan.in/gatsby-bulma-default/.

How to use this starter pack for your own project

I have already published it on npm and have hosted it on GitHub so it's quite easy if you want to start a Gatsby project with this template. Just do -

> gatsby new my-site-name https://github.com/aviaryan/gatsby-bulma-default

And then cd to the project folder and run it.

> gatsby develop

Concluding Words

There are some Gatsby templates that already have Bulma preinstalled. But all of them include Bulma with some other components that many folks might not want. So I thought of creating a clean Bulma starter template. It is simple and offers complete flexibility who wants to build on a Gatsby + Bulma stack.

For the record, here are the projects that are closest to mine. But as I have mentioned, they include other things that might get in the way of anyone looking for a clean slate.

Sort:  

Hello, I must say that it was really easy to go through this post. It was clear, well written and I really like the images with the code. However, as all contributions are related to a particular project, I fail to see big changes you added to integrate Bulma. There were only a few changes made, which happened most likely because the original template was simple as well.

Please understand that for this reason, the final score was adjusted slightly and was not completely followed by our review questionnaire.

Anyway, keep up the good work.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thanks. I understand that.

Hey @the-dragon
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.22
TRX 0.25
JST 0.039
BTC 95759.82
ETH 3324.32
USDT 1.00
SBD 3.17