Gatsby plugins are Node.js packages that you can add to your site. Plugins let you quickly add new features to your Gatsby site without needing to build them from scratch.
In this guide, you’ll learn how to install and configure a plugin.
PrerequisitesBefore you begin, you should already have:
The general process for adding a plugin to your site looks like this:
gatsby-config.js
file.In this guide, you’ll add the gatsby-plugin-sitemap
plugin to your Gatsby site, but you can use a similar procedure with any other plugin.
Using a different plugin? Check the plugin’s README in the Gatsby Plugin Library for more details on how to set it up.
Step 1: Install the pluginAdd the plugin as a project dependency in your package.json
file by running the following command in the terminal:
Check the plugin’s README file to see if there are any other dependencies that you also need to install. (For example, gatsby-plugin-mdx
also requires @mdx-js/react
to be installed.)
gatsby-config.js
file
Your gatsby-config.js
file contains information about your site, including configuration for plugins.
To add a plugin to your site, add its name to the plugins
array in your gatsby-config.js
file:
Note: Generally, the order of plugins in your plugins
array isn’t important. In cases where order is important, the plugin README will have more details.
If your plugin requires additional configuration options, add a configuration object to your plugins
array instead of using a string with the plugin’s name. For example, here’s how you would configure gatsby-plugin-sitemap
with a different output
option:
Check the plugin README in the Gatsby Plugin Library for more information about the configuration options available.
Note: Plugin options will be stringified by Gatsby, so they cannot be functions.
Step 3: (When applicable) Use features from the plugin in your siteDifferent plugins provide different features that you can use in your Gatsby site.
For some plugins, like gatsby-plugin-sitemap
, you can skip this step. Once you add the plugin to your gatsby-config.js
file, the plugin handles the rest of the functionality automatically.
Other plugins might provide components or functions, which you then need to import and use in other files throughout your site. For example, the gatsby-plugin-image
plugin exports a <GatsbyImage>
component that you can use to add images to your site. Check the plugin’s README to see whether there are any additional steps you need to do to use the plugin in your site.
Start building today on
Netlify!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4