2 - Up and Running
  • bitly to slides
  • gatsby cli
  • commands
  • gatsby config
  • node APIs

Environment Dependencies

  • git

Check & direct TA to help if needed

Gatsby-CLI



The command gatsby new comes from the package Gatsby CLI. It is intended to be installed globally. Once we’ve correctly installed the Gatsby CLI, we should be able to run the command gatsby with the --version modifier to verify that it’s properly installed.

$ npm install -g gatsby-cli
$ gatsby-cli --version

Gatsby-CLI Commands


Here is a list of some common CLI commands that Gatsby CLI package provides:

$ gatsby new name-of-your-site url-to-starter # defaults to gatsby-starter-default
$ gatsby develop  # starts a hot reload server
$ gatsby build  # may be run by your deployment service
$ gatsby serve  # serves production build
$ gatsby info  # info about your system and your package
$ gatsby clean

  • gatsby new creates a new gatsby project. It should be run followed by the name of your project site, then followed by the starter you use. It defaults to use gatsby-starter-default if you do not provide the last argument.
  • gatsby develop starts a hot reload development server that you may use for development.
  • gatsby build builds your site targeting production. This is also the default build command used by deployment services such as Netlify. We’ll cover that later.
  • gatsby serve starts a server that serves production build after you’ve built it.
  • gatsby info prints out information about your system as well as your package.
  • And finally gatsby clean is useful when some issue (mainly caching) arrises in your development.

You may read about what they do in the doc page.

Setting up the site


$ gatsby new anyhowly-rocks https://github.com/Vagr9K/gatsby-advanced-starter

Let’s now go ahead and set up our site by running gatsby new.

Check

When you run gatsby new, what it does is that it clones your starter, installs dependencies, copies starter files, then remove the .git directory so you can initialize your own.