gatsby
Develop and build Gatsby websites
TLDR
Create a new site
Create a new site with a Gatsby 'starter'
Start a live-reloading local development server
Perform a production build and generate static HTML
Start a local server which serves the production build
SYNOPSIS
gatsby
PARAMETERS
new [projectName] [starter]
Creates a new Gatsby project. Optionally specify a project name and starter template.
Example: gatsby new my-blog https://github.com/gatsbyjs/gatsby-starter-blog
develop
Starts a local development server for your Gatsby project.
Flags: -p, --port: Port to run the server on, -H, --host: Host to serve the server from.
build
Builds your Gatsby project for production. Generates optimized static files in the `public` directory.
Flags: --prefix-paths: Build site with link paths prefixed (for subdirectories), --profile: Build with profiling information
serve
Serves the production build of your Gatsby project locally. Used for testing your built site.
Flags: -p, --port: Port to run the server on, -H, --host: Host to serve the server from.
clean
Deletes the `.cache` and `public` directories, useful for clearing out stale data or fixing build issues.
info
Displays system and environment information relevant to Gatsby development.
plugin
Manages Gatsby plugins. Common commands include `docs` to open plugin documentation. Not officially part of the gatsby-cli anymore. Most often handled by npm/yarn.
repl
Launches an interactive GraphQL REPL (Read-Eval-Print Loop) for exploring your Gatsby data. Useful for testing GraphQL queries.
telemetry
Enable or disable Gatsby telemetry. Usage `gatsby telemetry --disable|--enable`
DESCRIPTION
Gatsby is a free and open-source framework based on React that helps developers build blazing fast websites and apps. It leverages modern web standards to provide a performant, secure, and scalable platform for content delivery. Gatsby pulls data from various sources, including CMSs, APIs, databases, and Markdown files, then generates static HTML, CSS, and JavaScript at build time. This results in extremely fast page load times and improved SEO. Gatsby promotes a modern developer workflow by integrating with tools like GraphQL and Webpack and offering a rich plugin ecosystem. It's often used for blogs, documentation sites, e-commerce sites, and progressive web applications (PWAs). Gatsby focuses on developer experience offering features like hot reloading, prefetching, and built-in routing that simplifies web development.
Gatsby isn't a single command, but rather a CLI tool (`gatsby-cli`) that provides access to multiple subcommands and options for managing Gatsby projects.
CAVEATS
Gatsby relies on Node.js and npm (or yarn) for installation and project management. You need to have these tools installed before using Gatsby. The `gatsby-cli` is installed globally, but project dependencies are managed locally within each Gatsby project.
STARTERS
Gatsby starters are pre-configured Gatsby projects that provide a foundation for building different types of websites. They often include basic configurations, themes, and data sources to get you started quickly. Many community-created starters are available.
GRAPHQL DATA LAYER
Gatsby uses GraphQL to expose data from different sources, such as Markdown files, APIs, and CMSs. You can use GraphQL queries to retrieve and transform data for use in your components.
PLUGINS
Gatsby plugins extend the functionality of Gatsby by adding new features, integrations, and optimizations. There are plugins for various tasks, such as image processing, data fetching, and SEO optimization. They are installed via npm/yarn.
HISTORY
Gatsby was created by Kyle Mathews and released in 2015. It was originally designed to be a static site generator based on React and GraphQL. Over the years, it has evolved into a powerful framework for building modern web applications. Gatsby's focus on performance and developer experience has made it a popular choice for developers building various types of websites and applications.