【问题标题】:Googles multilingual xml sitemap example is not rendering correctlyGoogle 的多语言 xml 站点地图示例未正确呈现
【发布时间】:2021-09-05 22:37:45
【问题描述】:

我正在实现多语言站点地图,Google 提供的 xml 示例在浏览器中访问时显示纯文本

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>http://www.example.com/english/page.html</loc>
    <xhtml:link
               rel="alternate"
               hreflang="de"
               href="http://www.example.com/deutsch/page.html"/>
    <xhtml:link
               rel="alternate"
               hreflang="de-ch"
               href="http://www.example.com/schweiz-deutsch/page.html"/>
    <xhtml:link
               rel="alternate"
               hreflang="en"
               href="http://www.example.com/english/page.html"/>
  </url>
  <url>
    <loc>http://www.example.com/deutsch/page.html</loc>
    <xhtml:link
               rel="alternate"
               hreflang="de"
               href="http://www.example.com/deutsch/page.html"/>
    <xhtml:link
               rel="alternate"
               hreflang="de-ch"
               href="http://www.example.com/schweiz-deutsch/page.html"/>
    <xhtml:link
               rel="alternate"
               hreflang="en"
               href="http://www.example.com/english/page.html"/>
  </url>
  <url>
    <loc>http://www.example.com/schweiz-deutsch/page.html</loc>
    <xhtml:link
               rel="alternate"
               hreflang="de"
               href="http://www.example.com/deutsch/page.html"/>
    <xhtml:link
               rel="alternate"
               hreflang="de-ch"
               href="http://www.example.com/schweiz-deutsch/page.html"/>
    <xhtml:link
               rel="alternate"
               hreflang="en"
               href="http://www.example.com/english/page.html"/>
  </url>
</urlset>

https://developers.google.com/search/docs/advanced/crawling/localized-versions?hl=en&visit_id=637599535586353543-2604365232&rd=2#sitemap

为什么浏览器中的 xml 渲染不正确?

【问题讨论】:

  • 你能分享一张谷歌将你的 XML 显示为纯文本的图片吗?
  • @LovekeshKumar snipboard.io/MuZcpe.jpg 这是谷歌站点地图示例在浏览器中访问时的样子

标签: xml seo sitemap


【解决方案1】:

这可能是您在文件标题中提供的content-type 的问题。

站点地图文件的内容类型应为text/xmlsitemap/xml

所以首先检查标题中的content-type 并将其更改为正确的类型。

【讨论】:

    猜你喜欢
    • 2013-12-18
    • 2016-05-09
    • 1970-01-01
    • 2020-10-15
    • 1970-01-01
    • 1970-01-01
    • 2023-02-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多