谷歌站点地图命名空间混乱

时间:2014-11-28 20:31:05

标签: xml namespaces sitemap

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

<?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>

以下是Google的错误消息:

  

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

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

2 个答案:

答案 0 :(得分:1)

通过替换解决了问题将xhtml命名空间添加到所有&#39;链接&#39;标签

更换

<link

<xhtml:link 

答案 1 :(得分:0)

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

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