Sitemap
Role and Creation Guide
A Sitemap (website map) is a file in XML or HTML format that includes all the pages of a website and helps search engines index the website more quickly and efficiently.
Manual Creation
Example of an XML format sitemap:
<!--?xml version="1.0" encoding="UTF-8"?-->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2025-02-28</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
</urlset>
If your website runs on Next.js, you can use the following code to generate a sitemap.
import { writeFileSync } from 'fs';
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>${new Date().toISOString()}</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
</urlset>`;
writeFileSync("public/sitemap.xml", sitemap);
User-agent: *
Sitemap: https://example.com/sitemap.xml
Thus, a sitemap is an essential tool for your website's SEO and should be properly structured to ensure search engines index your website as efficiently as possible.