规范链接指向站点根错误

Cha*_*wis 4 seo localization canonicalization canonical-link

我有一个使用特定国家/地区页面的网站。因此,对于每个页面,都有一个特定于国家/地区的 URL。例如:example.com/au/blogexample.com/us/blogexample.com/uk/blog。这很棒,因为我们可以展示与每个国家/地区更相关的内容。

这个想法和我们的主页是一样的:example.com/au, example.com/us, example.com/uk

当用户访问非特定国家/地区的 URL(即)时example.comexample.com/blog服务器将转而提供更通用的内容。然后,我们在客户端上显示一个横幅,供用户决定是否要访问特定于国家/地区的页面。

考虑到这一点,我添加了以下元标记,并在使用 Lighthouse 进行测试时收到以下错误。

<link rel="canonical" href="https://www.example.com/">
<link rel="alternate" hreflang="x-default" href="https://www.example.com/">
<link rel="alternate" hreflang="en-GB" href="https://www.example.comt/uk/">
<link rel="alternate" hreflang="en-US" href="https://www.example.com/us/">
<link rel="alternate" hreflang="en-AU" href="https://www.example.com/au/">
Run Code Online (Sandbox Code Playgroud)
//error
The document does not have a valid rel=canonical. Points to the domain's root URL (the homepage), instead of an equivalent page of content. 
Run Code Online (Sandbox Code Playgroud)

这是通知爬虫的正确方法吗:

  • 站点根目录是原始文档
  • 网站根目录不针对任何语言或区域设置
  • 此页面的替代选项是 en-GB、en-US 和 en-AU

如果是这样,为什么 Lighthouse 在主页上抱怨这个错误?它不会在任何其他页面上抱怨这一点。

我对规范化和提供替代语言页面不熟悉,所以我可能会遗漏一些明显的东西。

Raf*_*ael 5

由于您的主页具有通用的内容子集,因此它不是规范的。(规范上下文 IRI 和目标 IRI 不应相同,否则用户可能已位于规范 IRI 上。)从技术上讲,每种语言的 IRI 是规范文档备用文档,具体取决于语言。由于您在英国,因此您应该将 en-GB IRI 指定为规范 IRI,将其他 IRI 指定为替代项(而不是“替代项”),因为它们只是其中相同内容的不同表示。

从主页https://www.example.com/(广义内容):

<link rel="canonical" hreflang="en-GB" href="https://www.example.com/uk/">
Run Code Online (Sandbox Code Playgroud)

来自https://www.example.comt/uk/(规范的 IRI)

<link rel="alternate" hreflang="en-US" href="https://www.example.com/us/">
<link rel="alternate" hreflang="en-AU" href="https://www.example.com/au/">
Run Code Online (Sandbox Code Playgroud)

https://www.rfc-editor.org/rfc/rfc6596

https://www.rfc-editor.org/rfc/rfc8288

https://html.spec.whatwg.org/#the-link-element