วิธีรวมส่วนขยาย Sitemap
ส่วนขยาย Sitemap เป็นวิธีที่ดีในการบอกให้ Google ทราบเกี่ยวกับเนื้อหาประเภทต่างๆ และข้อมูลเมตาที่คุณใช้ในเว็บไซต์ บ่อยครั้งเนื้อหาในหน้าเว็บอาจอยู่ในส่วนขยายหลายประเภท เช่น คุณอาจเผยแพร่บทความข่าวที่ฝังรูปภาพและวิดีโอ นอกจากนี้ หน้าเว็บอาจมีเวอร์ชันแปลด้วย ซึ่งหมายความว่าคุณอาจเพิ่มคําอธิบายประกอบ hreflang สําหรับหน้าเว็บที่แปลแล้วได้
เนมสเปซ
สําหรับส่วนขยาย Sitemap แต่ละรายการที่ต้องการใช้ใน Sitemap คุณจะต้องระบุเนมสเปซที่เกี่ยวข้องซึ่งประกาศแท็กที่ส่วนขยายรองรับ ซึ่งทำได้ด้วยแอตทริบิวต์ xmlns ของแท็ก urlset เนมสเปซของส่วนขยาย Sitemap ที่ Google รองรับมีดังนี้
| แท็กส่วนขยายและคําจํากัดความเนมสเปซของแท็ก | |
|---|---|
image: |
http://www.google.com/schemas/sitemap-image/1.1
|
news: |
http://www.google.com/schemas/sitemap-news/0.9
|
video: |
http://www.google.com/schemas/sitemap-video/1.1
|
xhtml: (สำหรับ hreflang) |
http://www.w3.org/1999/xhtml
|
การประกาศเนมสเปซหลายรายการ
หากต้องการประกาศเนมสเปซหลายรายการ ให้เพิ่มการอ้างอิงเนมสเปซที่เกี่ยวข้องลงใน Sitemap ตามที่อธิบายไว้ในเอกสารประกอบของส่วนขยายนั้นๆ ต่อไปนี้คือตัวอย่างที่แสดงวิธีเพิ่มส่วนขยายข่าว วิดีโอ และ xhtml (สำหรับ hreflang) ลงใน Sitemap
<?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"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<!-- rest of the sitemap -->การรวมส่วนขยาย Sitemap
เมื่อประกาศเนมสเปซแล้ว ให้ทําตามรายละเอียดการใช้งานในเอกสารประกอบของส่วนขยาย Sitemap ที่เกี่ยวข้อง
หากต้องการรวมส่วนขยาย ให้เพิ่มแท็กจากส่วนขยาย Sitemap ที่ต้องการทีละแท็กลงในแท็ก <url> ที่เหมาะสมตามที่อธิบายไว้ในเอกสารประกอบของส่วนขยาย Sitemap แต่ละรายการ
ตัวอย่างวิธีเพิ่มส่วนขยายข่าว วิดีโอ และ xhtml (hreflang) ลงใน Sitemap
<?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" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <url> <loc>https://www.example.com/english/page.html</loc> <!-- Starting with the news extension tags --> <news:news> <news:publication> <news:name>The Example Times</news:name> <news:language>en</news:language> </news:publication> <news:publication_date>2008-12-23</news:publication_date> <news:title>Companies A, B in Merger Talks</news:title> </news:news> <!-- Next we add video extension tags --> <video:video> <video:thumbnail_loc>https://www.example.com/thumbs/123.jpg</video:thumbnail_loc> <video:title>Lizzi is painting the wall</video:title> <video:description> Gary is watching the paint dry on the wall Lizzi painted. </video:description> <video:player_loc> https://player.example.com/video/987654321 </video:player_loc> </video:video> <!-- And finally the xhtml tags for hreflang --> <xhtml:link rel="alternate" hreflang="de" href="https://www.example.de/deutsch/page.html"/> <xhtml:link rel="alternate" hreflang="de-ch" href="https://www.example.de/schweiz-deutsch/page.html"/> <xhtml:link rel="alternate" hreflang="en" href="https://www.example.com/english/page.html"/> </url> <!-- Add more <url> tags -->
ลําดับของส่วนขยายใน Sitemap ไม่เกี่ยวข้องกันหลังจากแท็ก <loc> อ่านแนวทางปฏิบัติแนะนําทั่วไปสําหรับ Sitemap โดยเฉพาะที่เกี่ยวกับขีดจำกัดขนาดไฟล์ การรวมส่วนขยาย Sitemap จะเพิ่มขนาดไฟล์ของ Sitemap อย่างมาก
Troubleshooting sitemaps
If you're having trouble with your sitemap, you can investigate the errors with Google Search Console. See Search Console's sitemaps troubleshooting guide for help.