我用AWS Amplify做了一个非常简单的盖茨比网站,网站地图不是由'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
获得