Closed V1laZ closed 3 months ago
This is not currently supported, it will require some work to get it to behave properly but is planned for some point.
13k URLs should not be an issue for Google.
I have the same issue with 94k urls
I'm curious if there's a way to detach form localizing the sitemap as at least it would not be grouped but i can construct the urls myself and have the plugin just chunk the result
I've made a temporary workaround until native support becomes available. I manually generate locale alternatives for each route and allow the module to handle the chunking process.
// nuxt.config.ts
sitemap: {
autoI18n: false,
sitemaps: true,
sources: [
'/api/sitemap-urls/'
]
}
// server/api/sitemap-urls.ts
interface SitemapUrl {
loc: string
lastmod: string
}
export default defineCachedEventHandler(async (event) => {
const config = useRuntimeConfig(event);
const response = await $fetch<SitemapUrl[]>(`${config.public.BACKEND_URL}/api/services/sitemap/`);
// Add languages here in ISO 639-1 format and optionally ISO 3166-1 Alpha-2 format
const locales = ['cs', 'sk', 'en-US', 'en-GB', 'es', 'de', 'fr', 'pl', 'it'];
return response.map(p => asSitemapUrl({
loc: `/${locales[0]}${p.loc}`,
lastmod: p.lastmod,
alternatives: locales.map(lang => ({
hreflang: lang,
href: `/${lang}${p.loc}`
})),
}));
}, { maxAge: 60 * 60 * 24 }) // cache for 24 hours
Describe the bug
When generating the sitemap with the i18n module and fetched dynamic URLs, it divides the sitemap into locale chunks. However, it fails to automatically further divide these chunks when they are too large, even with the
sitemaps: true
setting enabled.To reproduce
nuxt.config.ts with the following settings
sitemaps: true
. Locale chunks Inside the locale chunkExpected behavior
Either locale chunks should contain multiple chunked sitemap files if they are too large, or the sitemap should be chunked as a whole by the specified chunk size with locale paths.
Notes
I'm not sure if this is a problem with my settings, but I've tried multiple combinations and none worked. It either doesn't generate localized URLs, even when making my own endpoint and specifying
_i18nTransform: true
to every URL, or it chunks them by locales as described above.