LinuxCommandLibrary

gatsby

Develop and build Gatsby websites

TLDR

Create a new site

$ gatsby new [site_name]
copy

Create a new site with a Gatsby 'starter'
$ gatsby new [site_name] [url_of_starter_github_repo]
copy

Start a live-reloading local development server
$ gatsby develop
copy

Perform a production build and generate static HTML
$ gatsby build
copy

Start a local server which serves the production build
$ gatsby serve
copy

SYNOPSIS

gatsby <command> [options] [arguments]

Examples:
gatsby new my-gatsby-site
gatsby develop
gatsby build --prefix-paths

PARAMETERS

new <site-name> [starter-url]
    Initializes a new Gatsby project with a specified name and an optional starter template.

develop [--host <host>] [--port <port>]
    Starts a local development server for your Gatsby site, enabling live reloading and GraphQL Playground.

build [--prefix-paths] [--no-uglify] [--json]
    Compiles your Gatsby site into production-ready static HTML, CSS, and JavaScript files.

serve [--host <host>] [--port <port>]
    Serves the production build of your Gatsby site from the 'public' directory.

clean
    Deletes the '.cache' and 'public' directories, useful for troubleshooting build issues.

info
    Displays relevant information about your Gatsby environment, including Node.js, npm, and Gatsby CLI versions.

plugin <add|remove|docs> [plugin-name]
    Manages Gatsby plugins, allowing you to add, remove, or open documentation for a plugin.

DESCRIPTION

The gatsby command-line interface (CLI) is the primary tool for interacting with the Gatsby.js framework, a powerful and popular open-source framework for building fast, modern websites and web applications.

While not a native Linux command in the traditional sense, gatsby is a Node.js package that must be installed globally (e.g., via npm install -g gatsby-cli or yarn global add gatsby-cli). It allows developers to create, develop, build, and serve Gatsby projects directly from their terminal.

Gatsby leverages React for UI development, GraphQL for data querying, and Webpack for asset bundling, delivering highly optimized, performant, and secure static sites or Progressive Web Apps (PWAs). The gatsby CLI streamlines the development workflow by providing commands for common tasks like project initialization, starting a local development server with hot module reloading, creating production builds, and clearing build caches. Its focus on performance and developer experience makes it a staple for modern web development leveraging the JAMstack architecture.

CAVEATS

The gatsby command is a Node.js-based CLI tool and requires Node.js (typically v14.15.0 or higher) and a package manager like npm or Yarn to be installed on your system. It is not a native Linux utility or part of the GNU coreutils. Running gatsby without proper installation will result in a 'command not found' error.

DATA LAYER AND PLUGINS

Gatsby uses GraphQL as a data layer, allowing developers to pull data from various sources (local files, CMS, APIs) into their React components. The extensive plugin ecosystem further enhances functionality, providing integrations for images, markdown, third-party services, and more, all accessible and configurable via the gatsby CLI.

HISTORY

Gatsby was created by Kyle Mathews and first released in 2015. It gained significant traction for its innovative approach to static site generation, combining the power of React for dynamic UIs with the performance benefits of pre-rendered static assets. Its development has been driven by a strong focus on web performance, developer experience, and the adoption of modern web standards like GraphQL and Progressive Web Apps (PWAs). The gatsby CLI has evolved alongside the framework, adding new commands and options to support an ever-growing ecosystem of plugins and features.

SEE ALSO

npm(1), yarn(1), node(1), npx(1), webpack(1)

Copied to clipboard