Html 谷歌hreflang语言混乱:我必须为页面本身添加hreflang吗?

Html 谷歌hreflang语言混乱:我必须为页面本身添加hreflang吗?,html,seo,multilingual,google-webmaster-tools,Html,Seo,Multilingual,Google Webmaster Tools,在上,在2语言示例中,它表示: 想象一下,你有一个英文页面托管在 ,并在 . 你可以向谷歌表明西班牙语 URL是西班牙语中相当于英语页面的一个 三种方式: 标题中的HTML链接元素。在的HTML部分中,添加指向西班牙语的链接元素 该网页的版本位于,如下所示: <link rel="canonical" hreflang="en" href="http://janwawa.com/en/contact.php"> <!-- Alternate links are the sam

在上,在2语言示例中,它表示:

想象一下,你有一个英文页面托管在 ,并在 . 你可以向谷歌表明西班牙语 URL是西班牙语中相当于英语页面的一个 三种方式:

  • 标题中的HTML链接元素。在的HTML
    部分中,添加指向西班牙语的
    链接
    元素 该网页的版本位于,如下所示:

    <link rel="canonical" hreflang="en" href="http://janwawa.com/en/contact.php">
    <!-- Alternate links are the same for all pages  -->
    <link rel="alternate" hreflang="en" href="http://janwawa.com/en/contact.php">
    <link rel="alternate" hreflang="th" href="http://janwawa.com/th/contact.php">
    <link rel="alternate" hreflang="x-default" href="http://janwawa.com/default/contact.php">
    
    <link rel="canonical" hreflang="th" href="http://janwawa.com/th/contact.php">
    <!-- Alternate links are the same for all pages  -->
    <link rel="alternate" hreflang="en" href="http://janwawa.com/en/contact.php">
    <link rel="alternate" hreflang="th" href="http://janwawa.com/th/contact.php">
    <link rel="alternate" hreflang="x-default" href="http://janwawa.com/default/contact.php">
    
    
    
但在3种语言的例子中,它说:

如果URL有多个语言版本,则每个语言页面 必须识别所有语言版本,包括其本身。对于 例如,如果您的站点提供法语、英语和法语的内容 西班牙语,西班牙语版本必须包含rel=“alternate” hreflang=“x”除了与法语和法语的链接之外,还为自己提供了链接 英文版本。同样,英文版和法文版也必须相互兼容 包括对法语、英语和西班牙语的相同引用 版本

以上是一个3语言网站的例子。我的网站只有两种语言-默认/主要英语和泰语。我必须为页面本身添加标签吗?谷歌的文档并不清楚这一点,在其2语言网站的例子中,也没有提到这一点

例如,这是我放进去的


以上是正确的吗?或者我应该使用:


他们的文档页面有点糟糕,因为他们总是引用
hreflang=“x”
,其中
x
只是语言标记的占位符。语言标记
x
本身无效,因为它后跟连字符和字母数字字符串(
x-foo
):

privateuse=“x”1*(“-”(1*8alphanum)) 因此“[…]西班牙语版本本身必须包含一个
rel=“alternate”hreflang=“x”
链接[…]”是没有意义的

x-default
就是这样一个(有效的)私有语言标签,如果你想遵循谷歌对它的解释,那么只能使用
x-default

所以你的两个例子都不正确

你也应该

  • 仅包括到翻译的链接:

    
    
  • 或同时包括翻译链接和自引用链接:

    
    
我无法理解为什么谷歌会首先推荐一个自引用的
替代链接,并且假设它有任何意义,为什么他们不推荐只有两种语言的自引用链接


HTML5将引用定义为“当前文档的替代表示”。因此,使用
alternate
链接到当前文档是没有意义的,因为它不是“当前文档的替代表示”,而是当前文档。

如果您打算向中文用户显示英文页面,您确实可以使用第二个示例:

<!-- GOOGLE INTERNATIONAL LANGUAGE TARGETING -->
<link rel="alternate" hreflang="en" href="http://janwawa.com/en/contact.php">
<link rel="alternate" hreflang="th" href="http://janwawa.com/th/contact.php">
<link rel="alternate" hreflang="x-default" href="http://janwawa.com/en/contact.php">


新的x-default hreflang属性值向谷歌的算法发出信号,表明该页面不针对任何特定语言或区域设置,并且在没有其他页面更适合的情况下是默认页面-

,尽管我同意Unor的观点,即谷歌不清楚为什么建议使用自引用替代
链接,这是一个明确的声明:

如果URL有多个语言版本,则每个语言页面应标识不同的语言版本,包括其本身

对于备用链接未指定的语言或区域设置,说明:

对于不针对任何特定语言或语言的默认页面 区域设置,添加rel=“alternate”hreflang=“x-default”

所以,我会在这里使用另一个URL

此外,我还建议为每个页面添加一个
canonical
链接

示例

您的英文页面可能如下所示:

<link rel="canonical" hreflang="en" href="http://janwawa.com/en/contact.php">
<!-- Alternate links are the same for all pages  -->
<link rel="alternate" hreflang="en" href="http://janwawa.com/en/contact.php">
<link rel="alternate" hreflang="th" href="http://janwawa.com/th/contact.php">
<link rel="alternate" hreflang="x-default" href="http://janwawa.com/default/contact.php">
<link rel="canonical" hreflang="th" href="http://janwawa.com/th/contact.php">
<!-- Alternate links are the same for all pages  -->
<link rel="alternate" hreflang="en" href="http://janwawa.com/en/contact.php">
<link rel="alternate" hreflang="th" href="http://janwawa.com/th/contact.php">
<link rel="alternate" hreflang="x-default" href="http://janwawa.com/default/contact.php">

您的泰语页面可能如下所示:

<link rel="canonical" hreflang="en" href="http://janwawa.com/en/contact.php">
<!-- Alternate links are the same for all pages  -->
<link rel="alternate" hreflang="en" href="http://janwawa.com/en/contact.php">
<link rel="alternate" hreflang="th" href="http://janwawa.com/th/contact.php">
<link rel="alternate" hreflang="x-default" href="http://janwawa.com/default/contact.php">
<link rel="canonical" hreflang="th" href="http://janwawa.com/th/contact.php">
<!-- Alternate links are the same for all pages  -->
<link rel="alternate" hreflang="en" href="http://janwawa.com/en/contact.php">
<link rel="alternate" hreflang="th" href="http://janwawa.com/th/contact.php">
<link rel="alternate" hreflang="x-default" href="http://janwawa.com/default/contact.php">


虽然我不太了解x-default的用法,但我决定使用第二个示例,删除所有感谢您的指导。@LawrenceL:您可以使用
x-default
链接到
http://janwawa.com/
:非特定于一种语言的页面,b)用作语言选择器页面。我越来越困惑了。这就是我想要做的:如果观众的语言不是英语或泰语(在本例中,观众的语言是汉语),我希望观众转到英语页面。意思是,英语观众进入英语页面。泰国观众进入泰国网页。中国或任何其他非英语/非泰国观众进入英语页面。那么,我的标记是否应该是:我是否应该在我的原始问题中使用第二个示例(3行标记)?@LawrenceL.:此标记与自动重定向用户无关。它只是告诉我们:这是用这种语言翻译的这份文件。如何决定重定向用户取决于您。当中国用户访问泰语版本时,自动将其重定向到英语版本通常是个坏主意(因为如果他们决定这样做,他们将没有机会看到泰语版本)。所以你只需要提供一个语言转换程序。现在,对于您的首页,您可以使用
x-default
,因为此页不是特定于语言的,对吗?所以在这个页面上,你可以自由重定向,如果你想的话。我的网站没有中文版本。因此,如果中国观众正在搜索,我会向他们显示英文版的URL。我相信大多数中国人不会用泰语阅读。所以我想我会用第二个例子。