Sourcing data from local files
In this section, we will learn how to source and query data from local files. As we mentioned previously, when we say local files, we are referring to files located alongside the code in our repository.
Site metadata
A great place to store small reusable pieces of data is within the gatsby-config.js
file. Gatsby exposes the siteMetadata
property to the data layer so that you can retrieve it throughout your application. In the context of our website, I would suggest storing your website address, your name, your role, and a short bio here. If this is implemented consistently, whenever any of these pieces of information change, you can change the field once in siteMetadata
and see the change reflected across your whole site.
Tip
gatsby-config.js
is a file that you will often find growing quite large as you expand your Gatsby projects. To try and keep things ordered, try and reserve your siteMetadata
for a handful of small strings. If you are...