Tấn Phát Digital — Bài viết được biên dịch và Việt hóa từ tài liệu chính thức "Learn about sitemaps" và "Build and submit a sitemap" của Google Search Central. Đây là bài kỹ thuật chuyên sâu dành cho developer, technical SEO và webmaster muốn tối ưu khả năng crawl của Google.
Sitemap — "Bản đồ kho báu" cho Googlebot
Hãy tưởng tượng bạn có một thư viện 10,000 cuốn sách. Bạn muốn người đọc tìm được sách họ cần. Bạn có 2 lựa chọn:
Lựa chọn 1: Cho người đọc tự đi loanh quanh, may rủi tìm thấy
Lựa chọn 2: Cung cấp danh mục có hệ thống — "Truyện tiếng Việt ở khu A, sách lịch sử ở khu B..."
Lựa chọn 2 hiệu quả hơn 100 lần. Sitemap chính là "danh mục thư viện" cho website.
Với Googlebot có crawl budget hữu hạn, sitemap giúp:
Không bỏ sót trang quan trọng
Crawl nhanh hơn
Index hiệu quả hơn
Phát hiện content mới sớm hơn
Bài viết này, Tấn Phát Digital sẽ hướng dẫn mọi thứ về XML sitemap — từ cơ bản đến nâng cao.
Bài viết này dành cho:
Developer xây dựng website
Technical SEO chuyên về crawl/index
Webmaster muốn website được crawl tốt
Chủ website muốn hiểu sitemap
Phần 1: Sitemap là gì?
1.1. Định nghĩa từ Google
Google định nghĩa:
"Sitemap là một FILE nơi bạn provide information về các pages, videos, và files khác trên site, và RELATIONSHIPS giữa chúng. Search engines như Google đọc file này để crawl site bạn HIỆU QUẢ HƠN."
Sitemap tell Google:
Trang nào quan trọng
Khi nào trang được updated lần cuối
Phiên bản ngôn ngữ khác (hreflang)
Hình ảnh, video, news liên quan
1.2. Các loại sitemap
Loại 1: XML Sitemap (Phổ biến nhất)
Dành cho search engines. Format:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/page</loc>
<lastmod>2026-05-21</lastmod>
</url>
</urlset>
Loại 2: HTML Sitemap
Dành cho users. Là trang web liệt kê liên kết.
→ Useful cho UX, không bắt buộc cho SEO.
Loại 3: Sitemap Extensions
Specialized sitemaps:
Image sitemap — Hình ảnh
Video sitemap — Videos
News sitemap — Tin tức
Xem thêm: Công cụ Sitemap Generator - Tạo Sitemap XML Online Tấn Phát Digital
Phần 2: Bạn có cần sitemap không?
2.1. Khi NÀO cần sitemap?
Google nói rõ 4 trường hợp nên có:
Trường hợp 1: Site lớn
"Generally, trên large sites khó đảm bảo every page được linked bởi at least one other page."
→ Site > 500 pages → CẦN sitemap.
Trường hợp 2: Site mới
"Site của bạn NEW và có FEW EXTERNAL LINKS."
→ Site mới không có backlinks → Google khó tìm → CẦN sitemap.
Trường hợp 3: Nhiều rich media
"Site có nhiều rich media content (video, images) hoặc shown in Google News."
→ Có nhiều video/hình → CẦN sitemap + specialized sitemaps.
Trường hợp 4: Update thường xuyên
Site cập nhật nhiều/ngày → Sitemap giúp Google biết content mới.
2.2. Khi nào KHÔNG cần?
Google nói:
Tình huống 1: Site nhỏ
"Site 'small' — khoảng 500 pages hoặc fewer."
Tình huống 2: Internal linking tốt
"Site comprehensively linked internally."
Tình huống 3: Không có rich media
Site chủ yếu là text → Sitemap không cần thiết lắm.
2.3. Khuyến nghị Tấn Phát Digital
Nên có sitemap nếu:
✅ Ecommerce (luôn cần) ✅ Blog/news (luôn cần) ✅ Site > 100 pages ✅ Site mới (< 6 tháng) ✅ Multi-language site ✅ Có video/image library lớn
→ Với 95% website, có sitemap luôn tốt hơn không có.
Phần 3: Sitemap không phải "magic"
⚠️ Quan trọng:
"Sitemap helps search engines DISCOVER URLs, nhưng nó DOESN'T GUARANTEE rằng tất cả items trong sitemap sẽ được crawled và indexed."
Sitemap KHÔNG:
Đảm bảo trang được index
Đảm bảo ranking
Thay thế internal linking
Sửa technical issues khác
Sitemap CHỈ:
Help Google discover URLs nhanh hơn
Provide metadata về URLs
Suggest trang quan trọng
→ Cần kết hợp với internal linking tốt + content quality.
Phần 4: Tạo XML Sitemap — Hướng dẫn chi tiết
4.1. Format chuẩn
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2026-05-21</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://example.com/blog/</loc>
<lastmod>2026-05-20</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://example.com/about</loc>
<lastmod>2026-01-15</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
</urlset>
4.2. Giải thích các elements
<urlset> (BẮT BUỘC)
Container cho toàn bộ sitemap, có namespace.
<url> (BẮT BUỘC)
Container cho mỗi URL.
<loc> (BẮT BUỘC)
URL của trang. Phải absolute (có https://) và URL-encoded.
<!-- Đúng -->
<loc>https://example.com/san-pham/ao-thun</loc>
<!-- Sai - relative -->
<loc>/san-pham/ao-thun</loc>
<!-- Sai - không có scheme -->
<loc>//example.com/san-pham</loc>
<!-- Cần URL-encoding nếu có ký tự đặc biệt -->
<loc>https://example.com/page?id=1&cat=2</loc>
<!-- & phải thành & -->
<lastmod> (OPTIONAL nhưng RECOMMENDED)
Ngày trang được update lần cuối. Format W3C Datetime:
<!-- Date only -->
<lastmod>2026-05-21</lastmod>
<!-- Date + time -->
<lastmod>2026-05-21T15:30:00+07:00</lastmod>
⚠️ Quan trọng: Phải là ngày update THẬT. Đừng giả mạo ngày để "fresh" — Google sẽ ignore nếu không tin.
<changefreq> (OPTIONAL)
Tần suất thay đổi. Values:
alwayshourlydailyweeklymonthlyyearlynever
⚠️ Lưu ý: Google hầu như IGNORE changefreq. Đây là legacy field.
<priority> (OPTIONAL)
Mức ưu tiên 0.0 - 1.0. Default = 0.5.
⚠️ Lưu ý: Google cũng IGNORE priority. Đây là legacy.
→ Tập trung vào <loc> và <lastmod> là đủ.
4.3. Sitemap tối ưu (modern format)
Hiện nay khuyến nghị:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2026-05-21</lastmod>
</url>
<url>
<loc>https://example.com/blog/</loc>
<lastmod>2026-05-20</lastmod>
</url>
</urlset>
→ Chỉ cần <loc> và <lastmod>.
Phần 5: Quy tắc giới hạn
Google có strict limits cho sitemap:
5.1. Limits chính
Yếu tố | Giới hạn |
|---|---|
URLs per sitemap | 50,000 |
File size (uncompressed) | 50 MB |
File size (compressed .gz) | 50 MB |
5.2. Khi vượt giới hạn
Nếu site > 50,000 URLs hoặc file > 50MB, dùng sitemap index file:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemap-products.xml</loc>
<lastmod>2026-05-21</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-blog.xml</loc>
<lastmod>2026-05-20</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-categories.xml</loc>
<lastmod>2026-05-19</lastmod>
</sitemap>
</sitemapindex>
→ Sitemap index có thể chứa đến 50,000 sitemaps.
→ Tổng cộng có thể đến 2.5 tỷ URLs.
5.3. Chiến lược chia sitemap
Theo loại content:
sitemap-index.xml
├── sitemap-products.xml (50k products)
├── sitemap-categories.xml (200 categories)
├── sitemap-blog.xml (5k blog posts)
├── sitemap-pages.xml (50 static pages)
└── sitemap-images.xml (image sitemap)
Theo ngày tháng (cho news/blog lớn):
sitemap-index.xml
├── sitemap-2026-05.xml (posts tháng 5/2026)
├── sitemap-2026-04.xml
├── sitemap-2026-03.xml
└── ...
Phần 6: Specialized Sitemaps
6.1. Image Sitemap
Cho site có nhiều hình ảnh quan trọng:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>https://example.com/san-pham/ao-thun</loc>
<image:image>
<image:loc>https://example.com/photos/ao-trang-1.jpg</image:loc>
<image:title>Áo thun nam cotton trắng</image:title>
<image:caption>Áo thun nam dáng regular fit</image:caption>
</image:image>
<image:image>
<image:loc>https://example.com/photos/ao-trang-2.jpg</image:loc>
</image:image>
<image:image>
<image:loc>https://example.com/photos/ao-trang-3.jpg</image:loc>
</image:image>
</url>
</urlset>
Tối đa 1,000 images per URL.
6.2. Video Sitemap
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url>
<loc>https://example.com/video-page</loc>
<video:video>
<video:thumbnail_loc>https://example.com/thumbs/video1.jpg</video:thumbnail_loc>
<video:title>Cách Pha Cà Phê Đúng Chuẩn</video:title>
<video:description>Hướng dẫn pha cà phê arabica chuẩn barista</video:description>
<video:content_loc>https://example.com/videos/video1.mp4</video:content_loc>
<video:duration>600</video:duration>
<video:publication_date>2026-05-21T08:00:00+07:00</video:publication_date>
<video:family_friendly>yes</video:family_friendly>
</video:video>
</url>
</urlset>
6.3. News Sitemap
Cho news publishers (cần được Google News approval trước):
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
<url>
<loc>https://news.example.com/bao-bong-da-hom-nay</loc>
<news:news>
<news:publication>
<news:name>Báo Bóng Đá Online</news:name>
<news:language>vi</news:language>
</news:publication>
<news:publication_date>2026-05-21T10:30:00+07:00</news:publication_date>
<news:title>Việt Nam vô địch SEA Games 2026</news:title>
</news:news>
</url>
</urlset>
Limit: 1,000 URLs per news sitemap, chỉ chứa articles <2 ngày.
Phần 7: Submit Sitemap cho Google
7.1. Cách 1: Search Console (Khuyến nghị)
Bước 1: Vào Search Console → Chọn property
Bước 2: Sidebar → Sitemaps
Bước 3: Nhập URL sitemap (vd: sitemap.xml)
Bước 4: Click Submit
Sau khi submit:
Google sẽ crawl sitemap
Show số URLs detected
Show errors nếu có
7.2. Cách 2: robots.txt
Add vào robots.txt:
User-agent: *
Allow: /
Sitemap: https://example.com/sitemap.xml
Sitemap: https://example.com/sitemap-products.xml
→ Có thể list nhiều sitemaps.
7.3. Cách 3: Ping Google (Deprecated)
❌ Google đã deprecate ping endpoint (/ping?sitemap=) từ 2023.
→ Dùng Search Console hoặc robots.txt.
7.4. Cách 4: Submit qua URL Inspection (cho 1 URL)
Cho URLs riêng lẻ:
URL Inspection Tool
Nhập URL
Request Indexing
Phần 8: Sitemap Generation cho các platforms
8.1. WordPress
Plugin recommended:
Yoast SEO — Auto-generate
/sitemap_index.xmlRank Math — Auto-generate
/sitemap_index.xmlGoogle XML Sitemaps — Plugin chuyên sitemap
Default WordPress (từ 5.5):
WordPress core auto-generate /wp-sitemap.xml.
8.2. Shopify
Shopify auto-generate tại /sitemap.xml. Không cần config.
8.3. Magento 2
Marketing → SEO & Search → Site Map
→ Add Site Map
8.4. Next.js
// pages/sitemap.xml.js
const generateSitemap = (posts) => {
return `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${posts.map(({ slug, updatedAt }) => `
<url>
<loc>https://example.com/blog/${slug}</loc>
<lastmod>${updatedAt}</lastmod>
</url>
`).join('')}
</urlset>`;
};
export async function getServerSideProps({ res }) {
const posts = await fetchPosts();
const sitemap = generateSitemap(posts);
res.setHeader('Content-Type', 'text/xml');
res.write(sitemap);
res.end();
return { props: {} };
}
export default function Sitemap() { return null; }
8.5. Custom PHP
<?php
header('Content-Type: application/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php
// Lấy URLs từ database
$urls = $db->query("SELECT slug, updated_at FROM products WHERE status='active'");
foreach ($urls as $url) {
echo '<url>';
echo '<loc>https://example.com/san-pham/' . htmlspecialchars($url['slug']) . '</loc>';
echo '<lastmod>' . date('Y-m-d', strtotime($url['updated_at'])) . '</lastmod>';
echo '</url>';
}
?>
</urlset>
Phần 9: Best Practices
Best Practice 1: Chỉ include canonical URLs
❌ Sai: Include URL có redirect
✅ Đúng: Chỉ include URLs returning 200 OK
Best Practice 2: Chỉ include indexable URLs
❌ Sai: Include URLs có noindex
✅ Đúng: Chỉ include URLs muốn được index
Best Practice 3: Update lastmod thật
❌ Sai: Set lastmod = hôm nay cho mọi URL
✅ Đúng: Chỉ update khi content thật sự thay đổi
Best Practice 4: HTTPS only (nếu site dùng HTTPS)
❌ Sai: Mix HTTP và HTTPS URLs
✅ Đúng: Tất cả URLs là HTTPS
Best Practice 5: Same domain
URLs trong sitemap PHẢI cùng domain với sitemap file.
sitemap tại: https://example.com/sitemap.xml
URLs phải là: https://example.com/...
KHÔNG được: https://other-domain.com/...
Best Practice 6: UTF-8 encoding
<?xml version="1.0" encoding="UTF-8"?>
Best Practice 7: Compress với gzip
sitemap.xml (50 MB)
sitemap.xml.gz (5 MB - compressed)
→ Submit .xml.gz cho server tiết kiệm bandwidth.
Phần 10: Common Errors và cách fix
Error 1: "Sitemap could not be read"
Nguyên nhân:
Server lỗi 5xx
Sitemap không accessible
robots.txt block
Fix:
Check server status
Test sitemap URL trong browser
Allow Googlebot trong robots.txt
Error 2: "URLs not accessible"
Nguyên nhân:
URLs trong sitemap return 404
URLs bị redirect
URLs có noindex
Fix:
Verify URLs returns 200
Remove redirected URLs
Remove noindex URLs
Error 3: "Invalid date format"
Nguyên nhân:
<lastmod>sai format
Fix:
Dùng W3C Datetime:
2026-05-21hoặc2026-05-21T15:30:00+07:00
Error 4: "URL not allowed"
Nguyên nhân:
URL cross-domain với sitemap
Fix:
Đảm bảo URLs cùng domain với sitemap
Error 5: "Too many URLs"
Nguyên nhân:
Hơn 50,000 URLs trong 1 sitemap
Fix:
Chia thành nhiều sitemaps
Dùng sitemap index
Phần 11: Monitoring Sitemap
Trong Search Console
Sitemaps Report:
Status (Success/Couldn't fetch/Has errors)
Type (XML/Image/Video/News)
Submitted URLs
Indexed URLs
Coverage Report:
Cross-reference với sitemap
Find URLs in sitemap nhưng not indexed
Find URLs indexed nhưng not in sitemap
KPIs để track
Metric | Healthy |
|---|---|
Submitted vs Indexed ratio | > 70% |
Errors | 0 |
Last read | Recent |
Kết luận
Sitemap là công cụ đơn giản nhưng mạnh mẽ trong arsenal SEO. Setup đúng = giúp Google crawl/index site bạn nhanh và hiệu quả.
5 thông điệp cuối
1. 95% website nên có sitemap. Đặc biệt ecommerce, blog, multi-language.
2. Focus vào <loc> và <lastmod>. <priority> và <changefreq> đã deprecated.
3. Chia nhỏ với sitemap index nếu site lớn.
4. Submit qua Search Console. Đừng quên add vào robots.txt.
5. Monitor regularly. Sitemap errors = SEO issues.
Tài liệu tham khảo
Về Tấn Phát Digital
Tấn Phát Digital triển khai sitemap optimization cho:
Site lớn (>100k URLs)
Ecommerce platforms
Multi-language sites
News publishers
Liên hệ để optimize sitemap strategy.
Biên soạn từ Google Search Central, 10/12/2025. Code samples và best practices thuộc về Tấn Phát Digital.
XML Sitemap là nền tảng quan trọng giúp website được crawl và index hiệu quả hơn trong chiến lược SEO hiện đại.
Nếu bạn muốn tối ưu Technical SEO và xây dựng website chuẩn Google, hãy liên hệ Tấn Phát Digital để được tư vấn.









