【问题标题】:Google sitemap namespace confusion谷歌站点地图命名空间混淆
【发布时间】:2015-01-27 12:26:46
【问题描述】:

这里是我的站点地图的结构:

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <sitemap>
        <loc>somefile.xml</loc>
    </sitemap>
</sitemapindex>

somefile.xml

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
  <loc>[some url]</loc>
  <link rel="alternate" hreflang="en" href="[some url]" />
  <link rel="alternate" hreflang="en" href="[some url]?lang=en" />
  <link rel="alternate" hreflang="fr" href="[some url]?lang=fr" />
  <priority>1.00</priority>
</url>

这是谷歌的错误信息:

您的站点地图或站点地图索引文件未正确声明 命名空间。预期:http://www.sitemaps.org/schemas/sitemap/0.9 找到:http://www.w3.org/1999/xhtml 标签:urlset

我想我遗漏了一些东西,互联网上的信息令人困惑。什么是正确的语法?如果你能提供帮助,谢谢。

【问题讨论】:

    标签: xml namespaces sitemap


    【解决方案1】:

    通过将 xhtml 命名空间添加到所有“链接”标签来解决问题。

    更换

    <link
    

    <xhtml:link 
    

    【讨论】:

      【解决方案2】:

      您应该将xmlns="http://www.w3.org/1999/xhtml" 添加到您的网址:

      <link rel="alternate" hreflang="en" href="[some url]" xmlns="http://www.w3.org/1999/xhtml" />
      

      【讨论】:

        猜你喜欢
        • 2012-09-06
        • 2012-03-29
        • 2014-04-14
        • 2016-01-04
        • 2022-06-17
        • 1970-01-01
        • 1970-01-01
        • 2023-01-30
        相关资源
        最近更新 更多