hreflang应该如何构建? [英] How the hreflang is supposed to be built?

查看:73
本文介绍了hreflang应该如何构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是

 < link rel =alternatehref =http://example.com / enhreflang =en> 
< link rel =alternatehref =http://example.com/ithreflang =it>

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

 < link rel =alternatehref =http://example.com/en/<?=$current ;?>中的hreflang = EN > 


解决方案

HTML5 定义


如果替代关键字与 hreflang 属性,并且该属性的值与根元素的语言不同,它表示所引用的文档是翻译。


翻译文档(即网页),而不是网站。 http://example.com/en code>链接至 http://example.com/it

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


My question is does the

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

should be like above an all pages or should be changed with the actual url of every page like:

<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.

So it’s for translated documents (i.e., pages), not sites.

http://example.com/en links to http://example.com/it,
http://example.com/en/hello links to http://example.com/it/ciao.

这篇关于hreflang应该如何构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆