sitemap.xml 不是由 Gatsby-plugin-sitemap 在 Amplify 中制作的

问题描述

我使用 AWS Amplify 创建了一个非常简单的 gatsby 站点站点地图不是由“gatsby-plugin-sitemap”创建的。

[package.json]

{
  "name": "web_matching","version": "1.0.0","private": true,"description": "web_matching","author": "uekyo","keywords": [
    "gatsby"
  ],"scripts": {
    "develop": "gatsby develop","start": "gatsby develop","build": "gatsby build","serve": "gatsby serve","clean": "gatsby clean"
  },"dependencies": {
    "gatsby": "^2.26.1","gatsby-plugin-sitemap": "^2.11.0","react": "^16.13.1","react-dom": "^16.13.1"
  }
}

[gatsby-config.js]

module.exports = {
  siteMetadata: {
    title: "web_matching",siteUrl: `https://amp.d1aw1cuurv9iud.amplifyapp.com`,},plugins: [
    {
      resolve: `gatsby-plugin-sitemap`,options: {
        output: `/sitemap.xml`,}
    }
  ]
};

[amplify.yml]

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
    build:
      commands:
        - yarn build
  artifacts:
    baseDirectory: public
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

你们有同样的经历吗?顺便说一下,如果我输入站点地图 URL,它会自动移动到首页。但是,它适用于本地主机。问题似乎出在 Amplify 上。

解决方法

使用 gatsby develop 在本地运行不会提供站点地图。

您必须通过运行 gatsby build && gatsby serve

在生产模式下运行

然后应该可以通过 http://localhost:9000/sitemap.xml

获得站点地图

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...