【发布时间】:2015-01-08 17:06:40
【问题描述】:
我有一个专为桌面设备设计和优化的页面foo.bar/root,现在我想告诉搜索引擎m.foo.bar/m-root 是同一个页面,但针对移动设备进行了优化,我该怎么做?
我应该在我的回复中添加什么样的标签(或 http 标头)来告诉亲爱的 Google 索引移动优化页面?
【问题讨论】:
我有一个专为桌面设备设计和优化的页面foo.bar/root,现在我想告诉搜索引擎m.foo.bar/m-root 是同一个页面,但针对移动设备进行了优化,我该怎么做?
我应该在我的回复中添加什么样的标签(或 http 标头)来告诉亲爱的 Google 索引移动优化页面?
【问题讨论】:
alternate link type“创建一个引用当前文档的替代表示的超链接”。使用link 元素,它可能看起来像:
<!-- on the desktop page <http://example.com/foo/> -->
<link href="http://m.example.com/foo/" rel="alternate">
您还可以使用media attribute 指定“资源适用于哪个媒体”(根据自己的喜好调整媒体查询):
<!-- on the desktop page <http://example.com/foo/> -->
<link href="http://m.example.com/foo/" rel="alternate" media="only screen and (max-width: 640px)">
这是普通的 HTML5 方式。
根据Google’s documentation,Google 似乎也能识别此标记。
【讨论】:
rel="alternate" 用于指出当前页面的替代页面(通常是不同的语言),我真的没有找到并知道media attr 先生,非常感谢。