谷歌SEO教程第21篇—如何结合使用站点地图扩展

站点地图扩展是将您要在网站上使用的各类内容及其元数据告知 Google 的绝佳方式。您网页上的内容通常会加入多种扩展;例如,您可能会发布嵌入图片和视频的新闻报道。此外,您的网页还可能会进行本地化,这可能意味着您可以为本地化网页添加 hreflang 注解。

对于您要在站点地图中使用的各站点地图扩展,您需要指定相应命名空间来声明受支持的标记。您可以借助 urlset 标记的 xmlns 属性来完成该步骤。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

如需声明多个命名空间,请按照对应扩展的文档中的说明,将相应的命名空间引用添加到您的站点地图中。以下示例演示了如何向站点地图添加新闻、视频和 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 -->

声明完命名空间后,请遵循您要使用的相应站点地图扩展的文档中的实现详情。

  • 图片站点地图
  • Google 新闻站点地图
  • 视频站点地图
  • hreflang

如需结合使用扩展,请按照各站点地图扩展的文档中的说明,将所需的站点地图扩展中的标记逐一添加到相应的 <url> 标记中。

例如,要向站点地图添加新闻、视频和 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>
    <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 -->

站点地图中扩展的顺序与 <loc> 标记后的内容无关。请遵循站点地图常规最佳实践,尤其是注意文件大小限制。组合使用站点地图扩展会大幅增加站点地图的文件大小。

文章为作者独立观点,不代表站长派立场,本文链接:https://zhanzhangpai.com/?p=4264

免责声明:本站部分内容来源互联网整理,如有侵权请联系站长删除。站长邮箱:1245911050@qq.com

(0)
上一篇 2023年3月18日 下午3:33
下一篇 2023年3月20日 下午3:36

相关推荐