gpt4 book ai didi

html - 我的 hreflang 标签有什么问题?

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:42:51 25 4
gpt4 key购买 nike

我最近在我的网站上添加了德语支持,现在我想在搜索结果中向讲德语的访问者显示我网站的德语版本,并向所有其他访问者显示英语版本。我已将此链接标记添加到我的默认页面 (https://example.com/):

桌面

<link rel="canonical" href="https://example.com/">
<link rel="alternate" media="only screen and (max-width:651px)" href="https://m.example.com/">
<link rel="alternate" href="https://example.com/" hreflang="x-default">
<link rel="alternate" href="https://example.com/?hl=de" hreflang="de">

移动

<link rel="canonical" href="https://example.com/">
<link rel="alternate" href="https://m.example.com/" hreflang="x-default">
<link rel="alternate" href="https://m.example.com/?hl=de" hreflang="de">

德语 版本的 hreflang 标签 (https://example.com/?hl=de):

桌面

<link rel="canonical" href="https://example.com/">
<link rel="alternate" media="only screen and (max-width:651px)" href="https://m.example.com/?hl=de">
<link rel="alternate" href="https://example.com/" hreflang="x-default">
<link rel="alternate" href="https://example.com/?hl=de" hreflang="de">

移动

<link rel="canonical" href="https://example.com/">
<link rel="alternate" href="https://m.example.com/" hreflang="x-default">
<link rel="alternate" href="https://m.example.com/?hl=de" hreflang="de">

但是我有一个问题。当我在 Google 上搜索 Youtube 时,它​​只返回德语版的 Youtube (https://www.youtube.com/?gl=DE&hl=de)。但是当我搜索我的网站时,谷歌默认显示我网站的英语版本,而德语版本显示为一个片段。我的代码有什么问题?

最佳答案

您实现的 canonical URL 不正确.

If you have a single page accessible by multiple URLs, or different pages with similar content (for example, a page with both a mobile and a desktop version), you should explicitly tell Google which URL is authoritative (canonical) for that page.

您有不同的桌面移动 站点,以及两种语言英语德语。它们提供不同的内容,您应该相应地更新规范 URL。

桌面

<link rel="canonical" href="https://example.com/">

移动

<link rel="canonical" href="https://m.example.com/">

桌面德语

<link rel="canonical" href="https://example.com/?hl=de">

移动德语

<link rel="canonical" href="https://m.example.com/?hl=de">

关于html - 我的 hreflang 标签有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47954287/

25 4 0