Node.js 盖茨比&x27;s插件生成的sitemap.xml返回404错误 解释
我正在使用为盖茨比网站生成Node.js 盖茨比&x27;s插件生成的sitemap.xml返回404错误 解释,node.js,http-status-code-404,gatsby,sitemap,netlify,Node.js,Http Status Code 404,Gatsby,Sitemap,Netlify,我正在使用为盖茨比网站生成sitemap.xml,但是,由于某种原因,我找不到,每当我尝试访问它时,它都返回404错误 例子 我创建并托管在Netlify上(与原版一样),以帮助调试 网址: sitemap.xml:(返回404) 提前感谢,, Luiz.这似乎是该库的一个已知错误,您可以在以下GitHub线程中看到: 也就是说,您可以降级到版本3.30,该版本似乎没有bug,并且注意使用选项。排除而不是选项。如果排除某些页面,则排除(尾随的“s”) 否则(同时),您可以将输出路
sitemap.xml
,但是,由于某种原因,我找不到,每当我尝试访问它时,它都返回404错误
例子
我创建并托管在Netlify上(与原版一样),以帮助调试
网址:
sitemap.xml:(返回404) 提前感谢,,
Luiz.这似乎是该库的一个已知错误,您可以在以下GitHub线程中看到:
3.30
,该版本似乎没有bug,并且注意使用选项。排除而不是选项。如果排除某些页面,则排除(尾随的“s”)
否则(同时),您可以将输出路径设置为/
,作为临时解决方法:
module.exports = {
plugins: [
{
resolve: "gatsby-plugin-sitemap",
options: {
output: "/",
query: `
{
allSitePage {
nodes {
path
}
}
allWpContentNode(filter: {nodeType: {in: ["Post", "Page"]}}) {
nodes {
... on WpPost {
uri
modifiedGmt
}
... on WpPage {
uri
modifiedGmt
}
}
}
}
`,
resolveSiteUrl: () => siteUrl,
resolvePages: ({
allSitePage: { nodes: allPages },
allWpContentNode: { nodes: allWpNodes },
}) => {
const wpNodeMap = allWpNodes.reduce((acc, node) => {
const { uri } = node
acc[uri] = node
return acc
}, {})
return allPages.map(page => {
return { ...page, ...wpNodeMap[page.path] }
})
},
serialize: ({ path, modifiedGmt }) => {
return {
url: path,
lastmod: modifiedGmt,
}
},
},
},
],
}
.谢谢你,费伦!我会坚持降级直到它被修复。