Getting Started with Gatsby

May 01, 2021

Although I’ve used React before, Gatsby was quite new to me. This post was born from the creation of this website. We needed something that would let us create a nice looking site very quickly. Gatsby looked like it might be the answer.

Installation

To install gatsby, you can do so from npm:



npm Install -g gatsby-cli

Creating a Project

You can start from scratch, but they have a number of template projects here for you to clone.

Running

Once you’ve cloned the template, you can run it:



gatsby develop

You’ll need to run this from whichever directory you have package.json in (typically the root directory).

That will run your project locally (usually on 8080).

Deploying

Once you’re happy that this works, you can deploy the site using the build command:



gatsby build

This will create a /public folder, which is, effectively, your website - you can now just copy this to wherever you’re serving the site from and you’re good to go.



Profile picture

A blog about one man's journey through code… and some pictures of the Peak District
Twitter

© Paul Michaels 2024