Install and use a plugin in a Gatsby site

Kyle Gill
InstructorKyle Gill
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 3 years ago

Learn how to extend a Gatsby site with an official or community authored plugin. Plugins are an important building block in the Gatsby ecosystem that allow you to leverage repeated Gatsby functionality across multiple Gatsby sites.

Plugins hook into the Gatsby lifecycle as sites build and allow you to source data from external APIs or CMSs, transform data, optimize images, and much more.

Learn more:

Kyle Gill: [00:00] The first step to adding a plugin to your Gatsby site is installing it and its dependencies. This video uses gatsby-source-filesystem, which is one of the most popular and commonly used plugins. Run npm install gatsby-source-filesystem. It will add support for including data in your site from files that are part of the local file system.

[00:18] After installing, you should see it show up in your package.json. Then, add the name of the plugin to your plugins array in the gatsby-config file. Plugins that are included as strings will run with default plugin options, but other plugins like gatsby-source-filesystem are configured by including them as objects and including an options key.

[00:45] Add gatsby-source-filesystem as an object and provide options of name and path which tells the plugin to pick up the files in my images folder. You can read about each plugin's specific options in its documentation.

[01:02] When you run gatsby develop or gatsby build, your plugins in the plugins array will also be run. For source plugins like the file system plugin, you can verify it installed and is running by navigating to http://localhost:8000/___graphql and querying for all files. The files from the folder you source should be included.

egghead
egghead
~ 21 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today