We recently released `getSitemap`
, a first-class way to create a sitemap for the pages you have built in a Makeswift custom host . The return type of getSitemap is:
type Sitemap = {
id: string
loc: string
lastmod?: string
changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never'
priority?: number
alternateRefs?: {
hreflang: string
href: string
}[]
}[]
It includes everything you need to create the XML response yourself, but you can also pass this data directly into `next-sitemap`'s `getServerSideSitemapLegacy` to create the XML automatically.
export async function getServerSideProps(ctx) {
const makeswift = new Makeswift('<makeswift_site_api_key>', { runtime })
const sitemap = await makeswift.getSitemap()
return getServerSideSitemapLegacy(ctx, sitemap)
}
export default function Sitemap() {}
For more details check out our new docs section on creating a sitemap.
Don't have a Next.js project yet? Get started with our no code builder and extend when you're ready.