Installation

I. Set up Dev environment

To set up our development server, we need to install Node.js, Git, and Gatsby CLI.

1. Install Node

If you’re using Mac, I recommend installing Node using Homebrew.

brew install node

For other operating systems, please check Node documentation for more information.

2. Install Git

  • For Mac: With Homebrew
brew install git

3. Install Gatsby CLI

Gatsby CLI tool lets us quickly create new Gatsby-powered sites and run commands.

To install Gatsby CLI globally

npm install -g gatsby-cli

To check a list of command and options, run:

gatsby --help

II. Create a Gatsby site

After installing Gatsby CLI, change into the directory where you want to store the project and run the following command

gatsby new <PROJECT NAME> <STARTER THEME>

For example

gatsby new my-gatsby-project https://github.com/gatsbyjs/gatsby-starter-hello-world

If we leave out the starter theme, Gatsby will use the default starter. Check more Gatsby Starter themes.

Then, navigate into your site’s directory and start

cd my-gatsby-project
gatsby develop

III. Gatsby commands

Here is a list of useful commands

  • gatsby develop: Start the Gatsby development server
  • gatsby build: Compile your application and make it ready for deployment
  • gatsby serve: Serve the production build for testing
  • gatsby clean: Wipe out .cache and public directories

IV. Useful pages