Sitemap XML (sitemap.xml) là file liệt kê tất cả URLs quan trọng của website, giúp search engine khám phá và index nhanh hơn. Format: <urlset> chứa nhiều <url>, mỗi url có <loc> (URL), <lastmod> (ngày cập nhật), <changefreq> và <priority> — lưu ý Google đã giảm tầm quan trọng của hai trường này từ ~2022 (vẫn giữ cho tương thích).
Khi nào CẦN: website lớn (>500 trang), trang mới tạo chưa có backlinks, website có nhiều content động (blog, e-commerce), trang deep link (>3 clicks từ homepage). Khi nào KHÔNG cần: website nhỏ (<50 trang) với navigation tốt.
Trong Next.js: dùng app/sitemap.ts export function trả về mảng URLs — Next.js tự generate sitemap.xml. Giới hạn: max 50,000 URLs hoặc 50MB mỗi sitemap, dùng sitemap index cho website lớn hơn.
An XML sitemap (sitemap.xml) is a file listing all important URLs on a website, helping search engines discover and index content faster. Format: <urlset> contains multiple <url> entries, each with <loc> (URL), <lastmod> (last modified date), <changefreq> and <priority> — note that Google de-emphasized these last two fields since ~2022 (keep them for compatibility but they have limited impact).
When you NEED one: large websites (>500 pages), newly launched sites without backlinks, sites with lots of dynamic content (blog, e-commerce), and pages that are deep in the site structure (>3 clicks from homepage). When you DON'T need one: small sites (<50 pages) with good navigation.
In Next.js: use app/sitemap.ts exporting a function that returns an array of URLs — Next.js auto-generates sitemap.xml. Limits: max 50,000 URLs or 50MB per sitemap; use a sitemap index for larger sites.