Next.js Discord

Discord Forum

Sitemap.ts file wrong format (html instead of xml)

Unanswered
ag. posted this in #help-forum
Open in Discord
ag.OP
Hey all! I am trying to create a sitemap.ts file. It's still pretty simple cause I did not want to include dynamic routes.

I generate the sitemap.ts file and have it in the app folder as follows:
import type { MetadataRoute } from "next";

export default function sitemap(): MetadataRoute.Sitemap {
  return [
    {
      url: "https://genist.io",
      lastModified: new Date(),
      changeFrequency: "yearly",
      priority: 1,
    },
    {
      url: "https://genist.io/terms",
      lastModified: new Date(),
      changeFrequency: "monthly",
      priority: 0.3,
    },
    {
      url: "https://genist.io/privacy",
      lastModified: new Date(),
      changeFrequency: "weekly",
      priority: 0.3,
    },
  ];
}


On Sitemap verification sites I get
1) GSC: Your Sitemap appears to be an HTML page. Please use a supported sitemap format instead.
2) xml sitemaps . com Incorrect http header content-type: "text/html; charset=utf-8" (expected: "application/xml")

0 Replies