如何合併 Sitemap 擴充元素
  Sitemap 擴充元素是讓 Google 瞭解您網站的各種內容及其中繼資料的好方法。網頁內容經常會搭配多種擴充元素;例如,您可能會發布嵌入圖片和影片的新聞報導。此外,您的網頁可能也會經過本地化,這表示您可以為本地化網頁加入 hreflang 註解。
命名空間
  針對您想在 Sitemap 中使用的每個 Sitemap 擴充元素,您必須指定會宣告擴充功能支援標記的個別命名空間。您可以藉由使用 urlset 標記的 xmlns 屬性來完成這項作業。Google 支援的 Sitemap 擴充元素命名空間為:
| 擴充元素標記及其命名空間定義 | |
|---|---|
| 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 中新增個別的命名空間參照。以下示範如何在 Sitemap 中新增新聞、影片和 xhtml (hreflang) 擴充元素:
    
<?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.