Skip to main content

Can Kuroco Generate an XML Sitemap?

Currently, there is no built-in feature to automatically generate an XML sitemap (sitemap.xml). Please implement the XML sitemap on the frontend.

How to Implement an XML Sitemap

In a headless CMS, content management (backend) and presentation (frontend) are separated. As a result, the actual URL structure, including the number of pages, is determined on the frontend. (The number of contents in Kuroco does not equal the number of pages.) Therefore, it is common practice to handle the XML sitemap on the frontend.

Basic Implementation Methods

The implementation method varies depending on the framework used. Please refer to the following documentation as an example when implementing an XML sitemap.

For example, in Next.js, you can generate an XML sitemap by creating a sitemap.ts (or sitemap.js) file in the app directory:

// app/sitemap.ts
import type { MetadataRoute } from 'next';

export default function sitemap(): MetadataRoute.Sitemap {
return [
{
url: 'https://www.diverta.co.jp/',
lastModified: new Date(),
changeFrequency: 'yearly',
priority: 1,
},
{
url: 'https://www.diverta.co.jp/about',
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.8,
},
{
url: 'https://www.diverta.co.jp/products',
lastModified: new Date(),
changeFrequency: 'weekly',
priority: 0.5,
},
];
}

This code generates the following XML:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.diverta.co.jp/</loc>
<lastmod>2024-01-06T15:02:24.021Z</lastmod>
<changefreq>yearly</changefreq>
<priority>1</priority>
</url>
<!-- Other URL entries -->
</urlset>

Support

If you have any other questions, please contact us or check out Our Slack Community.