Is it possible to serve AMP pages by user agent alone?

谁说我不能喝 提交于 2019-12-11 00:32:33

问题


My website is adaptive, rather than responsive in its construction, with different templates for different user agent classifications (mobile and desktop/tablet). We do this through strong user agent detection and serving the content back with the Vary: user-agent header (as per Google's guidelines)

I'd like to keep this structure when creating AMP pages - detecting the user based on their user agent and sending back an AMP template.

Is this possible, and if so, what is the user agent that AMP uses?


回答1:


AMP user agents are just regular web browsers, so there really isn't a way to disambiguate them from all other web traffic. This is by design.

You can still implement an adaptive design based on AMP, where you use AMP to build the pages you deliver to a subset of users. E.g. you could use AMP only for your users on phones and respectively chose the AMP template for them.




回答2:


Answer from George Crawford:

The GoogleBot requests the AMP pages with its UA details on webmaster central blog

However, this won't really help you, as this is the same UA as the regular GoogleBot. AMP pages need to be discoverable from their canonical page, which Google wants to crawl, so if you restrict Google to only see AMP pages, then it won't be able to find the canonical page, so it won't crawl your content correctly.




回答3:


Currently AMP search results are shown to mobile users only. And according to Google, a device is considered "mobile" if the display size is less than seven inches. So, from Google search results, you can just serve it to mobile devices.

Now, it would be a different story if you were to serve ALL of your pages using AMP, that is if I were to visit something like foo.bar or any other pages under that domain, I would be greeted with an AMP page, just like how ampproject.org is setup. But from my testing, the user agent isn't affected at all and should be identical to what you would get if it were a regular HTML page.



来源:https://stackoverflow.com/questions/39364431/is-it-possible-to-serve-amp-pages-by-user-agent-alone

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!