" hreflang="it"> " hreflang="x-defaul-6ren">
gpt4 book ai didi

php - hreflang 应该如何构建?

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

我的问题是

<link rel="alternate" href="http://example.com/en" hreflang="en">
<link rel="alternate" href="http://example.com/it" hreflang="it">

应该像上面的所有页面一样,或者应该用每个页面的实际 url 来改变,比如:

<link rel="alternate" href="http://example.com/en/<?=$current;?>" hreflang="en">
<link rel="alternate" href="http://example.com/it/<?=$current;?>" hreflang="it">
<link rel="alternate" href="http://example.com/<?=$current;?>" hreflang="x-default">

最佳答案

HTML5 defines :

If the alternate keyword is used with the hreflang attribute, and that attribute's value differs from the root element's language, it indicates that the referenced document is a translation.

因此它适用于翻译的文档(即页面),而不是网站。

http://example.com/en 链接到 http://example.com/it,
http://example.com/en/hello 链接到 http://example.com/it/ciao

关于php - hreflang 应该如何构建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31248004/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com