`Sitepage.context` no longer available in Gatsby v4 in generating sitemap.xml
See original GitHub issueAs documented in Here, it said we should query the allSitePage
and filter it with context
schema.
plugins: [
{
resolve: 'gatsby-plugin-sitemap',
... // skipped
query: `
{
site {
siteMetadata {
siteUrl
}
}
allSitePage(filter: {context: {i18n: {routed: {eq: false}}}}) {
edges {
node {
context {
i18n {
defaultLanguage
languages
originalPath
}
}
path
}
}
}
}
`,
... // skipped
}
}
}
];
However, as mentioned by Gatsby official: Field SitePage.context is no longer available in GraphQL queries
(source). If we still try to use the existing codes to generate sitemap through gatsby-plugin-sitemap, we will result in the following error:
Error executing the GraphQL query inside gatsby-plugin-sitemap:
Field "context" is not defined by type "SitePageFilterInput".
GraphQLError: Field "context" is not defined by type "SitePageFilterInput".
, and
ERROR
Error executing the GraphQL query inside gatsby-plugin-sitemap:
Cannot query field "context" on type "SitePage".
GraphQLError: Cannot query field "context" on type "SitePage".
Although the Gatsby official said we could create Sitepage.context manually as a workaround, it does not seem to be a good practice in the long term. Would there be any suggestion fix that satisfies the long-term goal? Thanks.
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
Migrating from v4 to v5 - Gatsby
This is a reference for upgrading your site from Gatsby 4 to Gatsby 5. Version 5 introduces the Slice API and Partial Hydration...
Read more >How to get updated / lastmod value for static files for sitemap ...
1. Use gatsby-source-filesystem to add the static page files to your filesystem so you can query them. In gatsby-config.js add the following ...
Read more >Gatsby.js — Sitemap and RSS Feed
Gatsby is a static web site framework that's based on React. We can use it to create static websites from external data sources...
Read more >How to Add a Sitemap and Robots.txt to a Gatsby Project
In this video, I demonstrate adding and configuring an XML Sitemap and a robots.txt file for a Gatsby site.We're going to be bringing...
Read more >Generate an SEO-Friendly Sitemap for your Gatsby Site
If you maintain a blog, documentation, or any other sort of writing-based Gatsby site, you know how much work goes into content creation....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here’s how I got the overall sitemap working again. I think the issue here is that people get stuck on the
siteUrl
error masking the real issue and don’t easily reach the discussion here.For those facing the same issue and wish to add back the context type as a quick workaround.
gatsby-node.js
in your root directory. (<PROJECT_DIR>/gatsby-node.js
)gatsby-node-js