站点地图不工作我无法获取站点地图网址,也无法使用/sitemap.xml网址,我该如何修复它??
siteMetadata: {
siteUrl: siteAddress.href, // which is "https://www.example.com/"
},
{
resolve: `gatsby-plugin-sitemap`,
options: {
head: true,
output: `/sitemap.xml`,
}发布于 2020-12-18 13:51:21
你试过构建你的项目吗?From the docs
注意:这个插件只有在生产模式下运行时才会生成输出!要测试您的站点地图,请运行:
gatsby build && gatsby serve
此外,您的插件选项无效:head应为createLinkInHead。包含查询的完整示例应如下所示:
{
resolve: `gatsby-plugin-sitemap`,
options: {
output: `/some-other-sitemap.xml`,
createLinkInHead: true,
exclude: [`/category/*`, `/path/to/page`],
query: `
{
wp {
generalSettings {
siteUrl
}
}
allSitePage {
nodes {
path
}
}
}`,
resolveSiteUrl: ({site, allSitePage}) => {
return site.wp.generalSettings.siteUrl
},
serialize: ({ site, allSitePage }) =>
allSitePage.nodes.map(node => {
return {
url: `${site.wp.generalSettings.siteUrl}${node.path}`,
changefreq: `daily`,
priority: 0.7,
}
})
}
}或者,您可以使用gatsby-plugin-advanced-sitemap,它具有更多可定制的选项。
https://stackoverflow.com/questions/65350914
复制相似问题