Sitemap XML là file định dạng XML liệt kê toàn bộ URL của website cần search engine crawl. Đây không phải ranking signal trực tiếp, nhưng là kênh chính để site công bố URL nào tồn tại — đặc biệt quan trọng cho site lớn, site mới, hoặc site có URL khó discover qua internal link. Bài này mô tả cấu trúc sitemap, sitemap index, cách generate trong WordPress và submit Search Console.
Định nghĩa sitemap XML
Sitemap XML được định nghĩa trong protocol sitemaps.org — chuẩn chung Google, Bing, Yandex hỗ trợ từ 2006. File XML đặt ở URL public (thường /sitemap.xml hoặc /sitemap_index.xml) liệt kê URL cùng metadata.
Khác biệt với:
- HTML sitemap: page list link cho user, không structured. Sitemap XML cho bot.
- RSS feed: liệt kê post mới gần đây. Sitemap liệt kê toàn bộ URL.
- Robots.txt: chỉ định URL nào bot KHÔNG crawl. Sitemap chỉ định URL bot NÊN crawl.
Cấu trúc sitemap XML
Sitemap đơn giản (1 file)
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://web22.dev/dich-vu/seo/</loc>
<lastmod>2026-05-09</lastmod>
<changefreq>weekly</changefreq>
<priority>0.9</priority>
</url>
<url>...</url>
</urlset>
Tag chính:
- <loc>: URL absolute, bắt buộc.
- <lastmod>: ngày update gần nhất, format ISO 8601 (
YYYY-MM-DDhoặc kèm time). Google dùng để prioritize re-crawl. - <changefreq>: always/hourly/daily/weekly/monthly/yearly/never. Google official confirm thường ignore vì plugin set không reflect thực tế.
- <priority>: 0.0 đến 1.0. Google cũng thường ignore vì subjective.
Net advice: invest time vào lastmod chính xác, không cần fine-tune changefreq/priority.
Sitemap index (nhiều file)
Sitemap có giới hạn 50,000 URL hoặc 50MB uncompressed. Site lớn vượt limit phải tách sitemap con và tham chiếu qua sitemap index:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://web22.dev/post-sitemap.xml</loc>
<lastmod>2026-05-09</lastmod>
</sitemap>
<sitemap>
<loc>https://web22.dev/page-sitemap.xml</loc>
</sitemap>
</sitemapindex>
Plugin Rank Math, Yoast tự generate sitemap index khi site lớn lên. Web22 hiện có 5 sitemap con: post, page, service, category, post_tag.
Cách hoạt động — bot xử lý sitemap
- Bot tải sitemap qua HTTP GET (URL submit hoặc khám phá qua robots.txt).
- Parse XML, extract URL list + lastmod.
- Queue URL vào crawl frontier — URL có lastmod mới được prioritize.
- Crawl từng URL, parse content.
- Update Coverage report trong Search Console.
Sitemap không bypass authority — URL trong sitemap vẫn cần internal link và backlink để rank tốt. Sitemap chỉ giúp bot biết URL tồn tại.
Submit sitemap qua 3 cách
1. Search Console Sitemap tool (chính thức)
- Login Google Search Console.
- Sidebar: Indexing → Sitemaps.
- Add new sitemap → nhập URL
sitemap_index.xml. - Status “Success” + URL count = OK.
Submit 1 lần, sau đó Google re-crawl tự động. Re-submit nếu sitemap URL thay đổi.
2. Robots.txt directive
Add line trong /robots.txt:
Sitemap: https://web22.dev/sitemap_index.xml
Mọi bot tải robots.txt sẽ thấy. Bing, DuckDuckGo, Yandex đều support.
3. IndexNow API (Bing, Yandex, Yep)
Real-time push khi URL update. Plugin Rank Math có module IndexNow. Google không dùng IndexNow.
Generate sitemap trong WordPress
Plugin Rank Math (Web22 dùng)
Sitemap module enabled mặc định. Settings → Sitemap Settings → toggle tag/post type. Plugin auto-update sitemap khi post publish/update. URL: /sitemap_index.xml.
Yoast SEO
Tương tự Rank Math. Settings → General → Features → XML Sitemaps. URL: /sitemap_index.xml.
Built-in WordPress sitemap (5.5+)
WordPress 5.5 có built-in sitemap tại /wp-sitemap.xml. Mặc định bật. Khi cài plugin SEO, plugin override built-in.
Custom sitemap
Khi cần kiểm soát hoàn toàn (loại CPT đặc biệt, custom logic), generate manually qua hook do_action('init', 'register_sitemap_provider'). Web22 dùng Rank Math + override một số endpoint.
Best practice cho sitemap
- Chỉ include URL canonical: không include URL có canonical về URL khác (sẽ bị Google flag warning).
- Loại URL noindex: URL có meta robots noindex không nên trong sitemap.
- Loại URL 404, redirect: sitemap clean. URL 301 redirect không nên trong sitemap.
- Lastmod chính xác: chỉ update khi content thực sự thay đổi đáng kể. Plugin auto-set lastmod = post_modified_date.
- Submit sitemap index, không từng sub-sitemap: Google tự discover sub-sitemap.
- Resubmit sau khi rebuild URL structure: sau khi rename slug/migrate, force re-submit.
Lỗi sitemap phổ biến
- Sitemap có URL 4xx/5xx: Search Console flag “Submitted URL not found (404)”. Audit và clean sitemap.
- Sitemap có URL noindex: Coverage report “Submitted URL marked ‘noindex'”. Loại URL noindex khỏi sitemap hoặc bỏ noindex.
- Sitemap có URL redirect 301: Coverage “Submitted URL has redirect”. Cập nhật sitemap với URL đích.
- Sitemap quá lớn: > 50MB hoặc > 50000 URL. Tách thành sitemap index.
- Sitemap không cập nhật khi rebuild: plugin cache cũ, force regenerate.
- Lastmod sai format: không phải ISO 8601 → bot ignore field.
- Encoding không UTF-8: URL có ký tự đặc biệt phải URL-encode đúng.
- Sitemap orphan: URL trong sitemap nhưng không có internal link — xem orphan pages.
Quan hệ với SEO khác
- Internal link — sitemap và internal link bổ sung nhau, không thay thế nhau.
- URL structure — URL clean, descriptive trong sitemap dễ Google parse.
- Canonical — sitemap chỉ chứa URL canonical, không variant.
- Redirect 301 — URL 301 không nên trong sitemap.
- Meta robots — URL noindex không nên trong sitemap.
- Index coverage — sitemap clean giảm warning trong Coverage.
- Crawl error — sitemap có URL lỗi tạo crawl error.
Câu hỏi thường gặp về sitemap XML
Site nhỏ < 100 URL có cần sitemap không?
Cần. Site nhỏ vẫn benefit từ sitemap vì giúp Google biết URL nào quan trọng và cập nhật khi nào. Plugin SEO tự generate, không tốn effort.
Sitemap submit 1 lần đã đủ chưa?
Đủ cho discover ban đầu. Sau đó Google tự re-crawl theo lastmod. Resubmit khi sitemap URL thay đổi (vd dùng plugin mới có endpoint khác).
Sitemap có thay thế internal link không?
Không. Sitemap giúp discover URL, internal link giúp distribute equity. Hai cơ chế khác nhau, đều cần thiết.
Image sitemap có riêng không?
Có. Schema image sitemap thêm tag <image:image>. Plugin Rank Math/Yoast tích hợp image vào sitemap chính qua extension. Hữu ích khi site nặng về image (e-commerce, gallery).
Sitemap có giúp index nhanh hơn không?
Giúp discover nhanh, không guarantee index. URL trong sitemap vẫn phải pass quality bar của Google. Site mới có sitemap được Google biết URL ngay nhưng có thể chờ 1-4 tuần để index thực sự.
Sitemap XML là baseline cho mọi site có ý định SEO — không phải tính năng cao cấp. Cần audit và clean sitemap, đặt SEO audit kỹ thuật hoặc tham khảo dịch vụ SEO Web22 — chi phí cụ thể tại bảng giá.


