You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example "How to add sitemap.xml for all language specific pages" here is not working and giving error:
Error: Pagearrayfrom`query`wasn't found at `data.allSitePage.nodes`.
Fix the custom query or provide a custom `resolvePages` function.
https://www.gatsbyjs.com/plugins/gatsby-plugin-sitemap/#api-reference
Gatsby version - "4.19.0"
"gatsby-plugin-sitemap" - "5.20.0"
"gatsby-plugin-react-i18next" - "2.0.1"
It can be fixed in this way:
// required as a serialize func don't get "siteUrl" value from a queryconstsiteUrl=`https://example.com`;
...
// plugin config{resolve: "gatsby-plugin-sitemap",options: {excludes: ["/**/404","/**/404.html"],query: ` { site { siteMetadata { siteUrl } } allSitePage(filter: {context: {i18n: {routed: {eq: false}}}}) { nodes { context { i18n { defaultLanguage languages originalPath } } path } } } `,serialize: (page)=>{const{ languages, originalPath, defaultLanguage }=page.context.i18n;consturl=`${siteUrl}${originalPath}`;constlinks=[{lang: defaultLanguage, url },{lang: "x-default", url },];languages.forEach((lang)=>{if(lang===defaultLanguage)return;links.push({ lang,url: `${siteUrl}/${lang}${originalPath}`});});return{
url,changefreq: "daily",priority: originalPath==="/" ? 1.0 : 0.7,
links,};},},}
Maybe demo Gatsby project and readme code sample are outdated?
The text was updated successfully, but these errors were encountered:
The example "How to add sitemap.xml for all language specific pages" here is not working and giving error:
Gatsby version - "4.19.0"
"gatsby-plugin-sitemap" - "5.20.0"
"gatsby-plugin-react-i18next" - "2.0.1"
It can be fixed in this way:
Maybe demo Gatsby project and readme code sample are outdated?
The text was updated successfully, but these errors were encountered: