首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复网站地图错误?

如何修复网站地图错误?
EN

Stack Overflow用户
提问于 2020-12-18 10:10:39
回答 1查看 249关注 0票数 1

站点地图不工作我无法获取站点地图网址,也无法使用/sitemap.xml网址,我该如何修复它??

代码语言:javascript
复制
  siteMetadata: {
    siteUrl: siteAddress.href, // which is "https://www.example.com/"
  },
 {
  resolve: `gatsby-plugin-sitemap`,
  options: {
    head: true,
    output: `/sitemap.xml`,
  }
EN

回答 1

Stack Overflow用户

发布于 2020-12-18 13:51:21

你试过构建你的项目吗?From the docs

注意:这个插件只有在生产模式下运行时才会生成输出!要测试您的站点地图,请运行:gatsby build && gatsby serve

此外,您的插件选项无效:head应为createLinkInHead。包含查询的完整示例应如下所示:

代码语言:javascript
复制
 {
    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,它具有更多可定制的选项。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65350914

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档