【问题标题】:sitemap.xml with hreflang tags - incorrect namespace带有 hreflang 标签的 sitemap.xml - 不正确的命名空间
【发布时间】:2019-10-30 21:09:48
【问题描述】:

这是我的sitemap.xml的格式

<?xml version="1.0" encoding="UTF-8"?>
<urlset
    xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
    xmlns:xhtml="https://www.w3.org/1999/xhtml"
    xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9
        https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
    <loc>https://example.com</loc>
    <xhtml:link 
               rel="alternate"
               hreflang="en-us"
               href="https://example.com" />
    <xhtml:link 
               rel="alternate"
               hreflang="en-gb"
               href="https://example.com/uk/" />
    <xhtml:link 
               rel="alternate"
               hreflang="x-default"
               href="https://example.com" />
</url>
</urlset>

但是,搜索控制台不断向我显示第 10 行名称空间不正确的错误。

我也尝试过这里提供的解决方案:XSD For Sitemap with HREFLANG

但我得到了同样的错误。我做错了什么?

【问题讨论】:

    标签: xml sitemap hreflang


    【解决方案1】:

    事实证明,Google 不喜欢 xmlns:xhtml="https://www.w3.org/1999/xhtml" 是 HTTPS。

    将其转换为非 HTTPs 似乎已经解决了这个问题,即

    <urlset
        xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
        xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9
            https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
    <url>
    

    它确实摆脱了浏览器视图中的默认 XML 样式,但站点地图会验证。如果需要,我想可以使用 XSL 自定义样式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-22
      • 1970-01-01
      • 2011-02-20
      • 1970-01-01
      • 2022-01-04
      • 1970-01-01
      • 2018-11-27
      • 2013-12-02
      相关资源
      最近更新 更多