我正在使用 nuxt.js sitemap-module生成 sitemap.xml
它与本地的 npm run build && npm run start
完美配合。
但是,在云端使用Nginx时就不行了。 https://vtapau.com/sitemap.xml
这是我的 Nginx 配置
server {
listen 80;
server_name vtapau.com www.vtapau.com;
location / {
proxy_pass http://localhost:8081/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_redirect off;
}
}
最佳答案
首先,我真的不知道这对您来说是否是有效的答案,正如您提到的您已将手动创建的站点地图放入静态文件夹中。
我认为您错误配置了站点地图,为了使 sitemap.xml 正常工作,您在站点地图对象内设置了路由:
// nuxt.config.js
{
sitemap: {
hostname: 'https://example.com',
gzip: true,
exclude: [
'/secret',
'/admin/**'
],
routes: [
'/page/1',
'/page/2',
{
url: '/page/3',
changefreq: 'daily',
priority: 1,
lastmod: '2017-06-30T13:30:00.000Z'
}
]
}
}
当我被要求选择语言时,我怀疑您的站点地图已分成不同的语言。我设法获得英文版站点地图here .
如果您的站点地图配置如下:
// nuxt.config.js
{
sitemap: {
hostname: 'https://example.com',
lastmod: '2017-06-30',
sitemaps: [
{
path: '/sitemap-foo.xml',
routes: ['foo/1', 'foo/2'],
gzip: true
}, {
path: '/folder/sitemap-bar.xml',
routes: ['bar/1', 'bar/2'],
exclude: ['/**']
}
]
}
}
您应该能够在 https://vtapau.com/sitemapindex.xml 获取站点地图。我希望这不是您创建的静态 xml,否则我已经无能为力了。 sitemap-module 中明确提到了此文档。 ,当配置错误时,请务必返回 github 文档或通过 github issues 找到答案。
- 也很高兴看到马来西亚在食品配送领域新成立了一家初创公司。
关于javascript - 404 在 nuxt.js 上找不到 sitemap.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61042722/