因此,我目前正在为具有多个店面的网站实施站点地图。
我使用nuxt sitemap module为静态页面(例如首页,条款和条件以及隐私权政策)生成了/sitemap/sitemap.xml
文件。
现在,该网站还为每个店面提供了动态路线,例如:mysite.com/store1
和mysite.com/store2
当前任务是为每个商店创建一个/sitemap.xml
,因此最终结果类似于:mysite.com/store1/sitemap.xml
此站点地图将包含与商店相关的所有内容,包括每种产品的动态子路线。
我目前不知道执行此操作的任何可能方法,我进行了很多搜索,但找不到任何内容。有什么想法吗?
答案 0 :(得分:1)
您可以按以下步骤创建站点地图索引:
{
sitemap: {
hostname: 'https://example.com',
path: '/sitemap.xml',
sitemaps: [
{
path: '/sitemap/sitemap.xml',
},
{
path: '/store1/sitemap.xml',
exclude: ['/**'],
routes: () => { /* return array of url for store #1 */ }
},
{
path: '/store2/sitemap.xml',
exclude: ['/**'],
routes: () => { /* return array of url for store #2 */ }
}
]
}
}
您将得到以下结果:
答案 1 :(得分:0)
尝试一下,它对我有用
sitemap: {
path: '/sitemap.xml',
hostname: process.env.BASE_URL,
cacheTime: 1000 * 60 * 15,
gzip: true,
generate: false,
sitemaps: [
{
path: '/sitemap/sitemap.xml',
},
{
path: '/store1/sitemap.xml',
exclude: [],
routes: async () => {
let apiUrl = 'your site url' // or API url
const { data } = await axios.get(`${apiUrl}store1`)
return data.data.map(v => `/${v.id}`)
}
},
{
path: '/store2/sitemap.xml',
exclude: [],
routes: async () => {
let apiUrl = 'your site url' // or API url
const { data } = await axios.get(`${apiUrl}store2`)
return data.data.map(v => `/${v.id}`)
}
},
{
path: '/store3/sitemap.xml',
exclude: [],
routes: async () => {
let apiUrl = 'your site url' // or API url
const { data } = await axios.get(`${apiUrl}store3`)
return data.data.map(v => `/${v.id}`)
}
},
]
}