#astro-sitemap duplicates
3 messages · Page 1 of 1 (latest)
Hi @rare reef. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Hello! Astro Sitemap can generate a sitemap with alternate pages. The serialize function receives a SitemapItem object, which can have a links property containing a list of LinkItem objects for alternate pages, including the parent page. Each LinkItem has two fields: url (the fully-qualified URL for the version of the page for the specified language) and lang (a supported language code targeted by this version of the page) source (https://docs.astro.build/en/guides/integrations-guide/sitemap#serialize).
Here's an example of how to use the serialize function in your astro.config.mjs:
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
export default defineConfig({
site: 'https://stargazers.club',
integrations: [
sitemap({
serialize(item) {
if (/your-special-page/.test(item.url)) {
item.changefreq = 'daily';
item.lastmod = new Date();
item.priority = 0.9;
}
return item;
},
}),
],
});