gatsby eslint travis-ci npm

Transform plain text into dynamic blogs and websites using React.js

3 years after

package gatsby channel on


Transform plain text into dynamic blogs and websites using the latest web technologies. A React.js static site generator.

Build sites like it's 1995. Files are translated into HTML pages at the same position within the file system. Add a markdown file at /docs/ and it'll be converted to /docs/index.html.

Supports Markdown, HTML, and React.js components out of the box. Easy to add support for additional files types.

Leverages [React Router's "nested component hierarchy"]( Overview) to make templating incredibly intuitive.

All templates, css, and content are hot reloadable.

live-reloading example


  • No-reload page transitions
  • Hot reload editing. Tweak your pages, templates, and styles and see changes in real time.
  • Make React.js component model and ecosystem available for building static sites
  • Intuitive directory-based URLs. The URL of a page is derived from its spot on the file system.
  • Support "Starters" — install starter sites directly from Github. Use open sourced starters or build your own.


Why use Gatsby instead of other Static Site Generators

  • No-refresh page transitions
  • The awesome React.js component model
  • Live editing on every part of your site. Dramatically speed development.

I'm already building a server-rendered React.js site, is Gatsby a good fit?

If you're site falls closer to the site end of the app<---->site spectrum then yes.

Gatsby is an excellent fit for blogs, marketing sites, docs sites, etc. Proper web apps should probably remain as normal web apps (though I'd love to be proved wrong!).


Gatsby is very new. APIs will break. Functionality is missing. It's usable but if you plan on building with it, expect a rocky road for some time.

Contributions welcome!

Getting started


npm install -g gatsby


  1. Create new Gatsby site gatsby new my-test-gatsby-site This creates the directory for your Gatsby project and adds the minimal files needed.
  2. cd my-test-gatsby-site
  3. gatsby serve — Gatsby will compile your code using Webpack and serve the site at localhost:8000
  4. See the tutorial below for more.

Gatsby Starters

The Gatsby cli tool lets you install "starters". These are partially built sites preconfigured to help you get moving faster on creating a certain type of site.

When creating a new site, you can optionally specify a starter to base your new site on e.g. gatsby new [URL_OF_STARTER]

For example, to quickly create a blog using Gatsby, you could install the Gatsby Starter Blog by running:

gatsby new blog

This downloads the files and initializes the site by running npm install

If you don't specify a custom starter, your site will created from the minimal default starter.

There are several starters that have been created. Create a PR to include yours!

Tutorial: Building a documentation site from the Gatsby Documentation Starter

  1. Install gatsby npm install -g gatsby
  2. Install documentation site starter gatsby new docs-site gh:gatsbyjs/gatsby-starter-documentation
  3. type cd docs-site
  4. type gatsby serve
  5. Open site in browser at localhost:8000. Verify clicking on links works.
  6. Try editing the site's config file config.toml. Change the siteTitle key. The site's title should change shortly after saving.
  7. Next try editing a doc page. Open /pages/docs/getting-started/ and edit it. Again any saved changes should load without refreshing in the browser.
  8. Add a new markdown page to the documentation. Copy the getting-started directory to some-additional-steps. Then edit the markdown file within the new directory. If you're familiar with other static site generation software, you'll be familiar with the "frontmatter" at the top of the file. Edit the title there + change the order to "5". Save this. Ideally this new file would be hot reloaded like other changes but I haven't figured out how to make this happen yet (help appreciated here). So to see your new page, restart gatsby serve and then refresh your browser.
  9. Build your site gatsby build. The site is built to the /public directory. Serve the site by going into the public directory and typing python -m SimpleHTTPServer

How Gatsby works

How files become pages

The process is file --> Webpack loader --> React.js wrapper component --> static html page.

Gatsby leverages Webpack extensively. Webpack is a sophisticated module bundler that can turn any sort of file into a commonjs module. Webpack uses "Loaders" to convert a file into a module. These loaded modules are then wrapped inside a react.js component that's specific to a given file type. Gatsby then generates a static html page from this component.

Gatsby ships with default loaders and wrappers for HTML, Markdown, and JSX/CJSX but for most projects you'll want to write your own loaders and wrappers (very easy to do).

As an example of how this process works, let's walk quickly through converting a markdown file into an html page.

The default Gatsby markdown loader parses the markdown into HTML and uses Highlight.js to syntax highlight code blocks.

Our markdown file.

title: This is a title

# Hi friends.
This is a markdown file.

When loaded and required, the resulting javascript object looks like the following.

  file: {
    // Information about file on disk e.g. extension, directory path, etc.
  data: {
    title: "This is a title",
    body: "<h1>Hi friends.</h1><p>This is a markdown file</p>"

Now Gatsby wraps the markdown file in this very simple React.js component.

module.exports = React.createClass({
  displayName: "MarkdownWrapper",

  render: function() {
    post =

    <div className="markdown">
      <div dangerouslySetInnerHTML={{__html: post.body}}/>

How to write your own loaders/wrappers

  • Coming...

Structure of a Gatsby site

  • /pages — All pages go here. Everything is turned into a page except files which start with an underscore
  • _template files — coming...

Sites built with Gatsby


Configuring Babel

Configuring babel-loader is as easy as creating a .babelrc in the root of the project. To enable stage 0 transforms, the following .babelrc could be used:

  "stage": 0

Related Repositories



Simple starter for Gatsby ...



Gatsby starter for creating a blog ...



The default Gatsby starter ...



Starter for building documentation site with GatsbyJS ...



The code to generate, a Gatsby-based blog. ...

Top Contributors

KyleAMathews gesposito ChristopherBiscardi phlogisticfugu


-   v0.7.7 zip tar
-   v0.7.6 zip tar
-   v0.7.5 zip tar
-   v0.7.4 zip tar
-   v0.7.3 zip tar
-   v0.7.2 zip tar
-   v0.7.1 zip tar
-   v0.7.0 zip tar
-   v0.6.2 zip tar
-   v0.5.0 zip tar
-   v0.4.3 zip tar
-   v0.4.2 zip tar
-   v0.3.2 zip tar
-   v0.3.1 zip tar
-   v0.2.4 zip tar
-   v0.2.2 zip tar
-   v0.1.0 zip tar
-   v0.0.3 zip tar
-   v0.0.2 zip tar
-   v0.0.1 zip tar
-   0.6.1 zip tar
-   0.4.1 zip tar
-   0.4.0 zip tar
-   0.3.0 zip tar
-   0.2.3 zip tar
-   0.2.1 zip tar
-   0.2.0 zip tar
-   0.1.0 zip tar