Next.js Discord

Discord Forum

Sitemap passing in Next13

Unanswered
Florida White posted this in #help-forum
Open in Discord
Florida WhiteOP
The old way to expose the sitemap was to use getServerSideProps in /pages directory. In the /app directory, we got the following approach:

import { MetadataRoute } from 'next'
 
export default function sitemap(): MetadataRoute.Sitemap {
  return [
    {
      url: 'https://acme.com',
      lastModified: new Date(),
    },
    {
      url: 'https://acme.com/about',
      lastModified: new Date(),
    },
    {
      url: 'https://acme.com/blog',
      lastModified: new Date(),
    },
  ]
}


My problem is that I am not actually generating the sitemap, I am getting it from the Strapi as an xml string. I need to pass it to the Next, but there is no string type available, only the MetadataRoute.Sitemap. How do I resolve this?

5 Replies

Florida WhiteOP
according to this website https://claritydev.net/blog/nextjs-dynamic-sitemap-pages-app-directory, that solution is for the Next13.2 and lower, im using Next13.3
@Florida White according to this website https://claritydev.net/blog/nextjs-dynamic-sitemap-pages-app-directory, that solution is for the Next13.2 and lower, im using Next13.3
sitemap.ts is for the case you make the sitemap data in the form of MetadataRoute.Sitemap

sitemap.xml is for the case you don’t need to generate the sitemap and instead have a xml content already

route.ts is for all other cases
Florida WhiteOP
thank you