Sitemap - how to use it? #444
Unanswered
spokospace
asked this question in
Q&A
Replies: 1 comment
-
You need to add the host for the environment (dev, pre, pro: beware it will be regenerated for each environment), then you can use it to ping crawlers and your site will be indexed, for example for Google: https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap
You also need to serve your sitemap.xml with For example, I'm using it without vite-ssg, just the vite version: // https://github.com/hannoeru/vite-plugin-pages
Pages({
extensions: ['vue', 'md'],
async onRoutesGenerated(routes) {
const hostname = process.env.SITE_MAP_URL // <== add this to your .env.<profile> file or use scripts with cross-env, check below
if (hostname) {
await generateSitemap({
routes: routes.filter((r) => {
// excluding some routes if required
return r.path !== '/this-route' && !r.path.startsWith('/and-this-routes')
}),
hostname,
})
}
},
}), "scripts": {
"dev": "vite",
"build-local": "cross-env SITE_MAP_URL=https://192.168.1.37:33013/ vite build --mode production --sourcemap",
"build-dev": "cross-env SITE_MAP_URL=https://mydevsite.domain.org/ vite build --mode production --sourcemap",
"build-pro": "cross-env SITE_MAP_URL=https://mysite.domain.org/ vite build --mode production",
"serve-dist": "vite preview"
}, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, is sitemap.xml should be generated automatically, or do we need to add some custom config to make it?
It seems it should be in the /public/sitemap.xml path, but I can't find any info.
Maybe there is someone who uses it, and can put some details?
Beta Was this translation helpful? Give feedback.
All reactions