Project structure
Last updated
Was this helpful?
Last updated
Was this helpful?
Now that you know how to start a Gatsby site from scratch, let’s pull down our more fleshed out repo with the project we will be working from for the remainder of this training, to save us some time.
If you haven’t done so already, visit the repo at and follow the Getting Started instructions to do so.
Now that we have our project up and running locally, let’s go into detail about a few of the files used by Gatsby.
This file defines our site's metadata, plugins, and other general configuration. This file is in the root of our Gatsby site.
Within the gatsby-config.js file, we hook up Gatsby to Drupal using the gatsby-source-drupal plugin.
IMPORTANT: Before Gatsby can query data from a Drupal website, Drupal’s needs to be enabled and an API end-point needs to be created. See video in the module's URL above for more details on how to ensure JSONAPI is properly configured.
This file lets you respond to actions within the browser, and wrap your site in additional components. The gives you many options for interacting with the of Gatsby.
The code in this file is run once in the process of building your site. You can use it to create pages dynamically, add nodes in GraphQL, or respond to events during the build lifecycle. To use the , create a file named gatsby-node.js in the root of your site. Export any of the APIs you wish to use in this file.
This file lets you alter the content of static HTML files as they are being Server-Side Rendered (SSR) by Gatsby and Node.js. To use the , create a file called gatsby-ssr.js in the root of your site. Export any of the APIs you wish to use in this file.