JPollock
JPollock

Reputation: 3558

How can I override the createPages query from a Gatsby theme?

I'm using the Gatsby theme blog. I installed it in a new site as documented here and everything works. I want to change the query for the main posts index. I see it in the theme's gatsby-node. How do I override it in my site?

Upvotes: 1

Views: 268

Answers (1)

EliteRaceElephant
EliteRaceElephant

Reputation: 8162

You need to use shadowing to replace the gatsby-node.js file. That means that you place your own gatsby-node.js file corresponding to the path of the theme gatsby-node.js file.

From the docs: Until we build tooling to support automatically handling shadowing, you will have to manually locate paths in a theme and create the correct shadowing paths in your site.

gatsby-node.js is a special file in the Gatsby build process. I don't know if "just replacing" is possible like that. If it does not work as easy as described in the docs I recommend to delete the main post index query in the theme and replacing it there with your own.

Upvotes: 1

Related Questions