标签: hreflang

用于多语言的 <xhtml:link rel="alternate" hreflang="" href=""/> 的 Sitemap.xml 无法在浏览器上正确呈现?

生成多种语言的站点地图:

按照 Google 的指示:

https://support.google.com/webmasters/answer/189077?hl=en

此代码:

<?xml version="1.0" encoding="UTF-8"?>
  <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
  <url>
    <loc>https://www.example.com</loc>
    <lastmod>${formattedDate}</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
  </url>
</urlset>
Run Code Online (Sandbox Code Playgroud)

结果(在浏览器中呈现):

在此输入图像描述

此代码(带有xhtml:link标签):

<?xml version="1.0" encoding="UTF-8"?>
  <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
  <url>
    <loc>https://www.example.com</loc>
    <lastmod>${formattedDate}</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
    <xhtml:link rel="alternate" hreflang="en-us" href="https://www.example.com"/>
    <xhtml:link rel="alternate" hreflang="en-ca" href="https://ca.example.com"/>
    <xhtml:link rel="alternate" hreflang="en-gb" href="https://uk.example.com"/>
  </url>
</urlset>
Run Code Online (Sandbox Code Playgroud)

结果(在浏览器中呈现):

在此输入图像描述


问题

似乎没有任何错误。但奇怪的是它没有像往常一样在浏览器中呈现 XML“页面”。

来自 Google的 https://www.google.com/gmail/sitemap.xml似乎也具有相同的行为(您可以检查它并看到响应包含一堆xhtml:link标签)。

我做错了什么还是添加这些标签时的正常行为xhtml:link

xml sitemap multilingual hreflang

6
推荐指数
0
解决办法
3253
查看次数

欧洲的 hreflang 标签

我一直都明白,因为没有en-EUIETF 标签,所以要以欧洲为目标,我必须为欧洲内的每个国家/地区使用en或列出一个hreflang

查看Think With Google的来源,我注意到以下几点:

<link rel="alternate" href="//thinkwithgoogle.com/intl/es-419/" hreflang="es-419" />
Run Code Online (Sandbox Code Playgroud)

它似乎使用联合国 M.49 代码来表示拉丁美洲和加勒比地区的西班牙语

联合国M.49维基百科页面还列出了欧洲码- 150

我是否可以使用以下hreflang标签来表示欧洲市场的英语?

<link rel="alternate" href="//example.com/intl/en-150/" hreflang="en-150" />
Run Code Online (Sandbox Code Playgroud)

html internationalization hreflang

5
推荐指数
0
解决办法
2203
查看次数