我正在使用nuxt.js sitemap-module来生成sitemap.xml It,它与本地的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;
}
}
发布于 2020-04-20 17:51:06
首先,我真的不知道这是不是有效的答案,就像你提到的,你已经将手动创建的站点地图放到了静态文件夹中。
我认为您错误地配置了站点地图,为了让sitemap.xml正常工作,您需要在sitemap对象中设置路由:
// 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。
如果您的sitemap配置如下:
// 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问题找到答案。
发布于 2020-04-12 19:18:57
我也面临着完全相同的问题。然后我发现,在生产服务器中,Nuxt服务器是使用nuxt start
启动的,而不是我在本地使用的nuxt-ts start
。这就是我的问题所在。希望这能对你有所帮助。
发布于 2020-04-19 07:27:02
在运行npm run build
之后重新启动PM2服务器。否则,/sitemap.xml将不会出现。
这就是我的情况。
我的sitemap模块配置:
sitemap: {
hostname: 'https://example.com',
gzip: true,
exclude: ['/exampleurl']
}
https://stackoverflow.com/questions/61042722
复制