且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Google AMP - 仅在通过 Google 搜索结果访问时显示启用 AMP 的页面

更新时间:2023-12-03 08:14:34

是否要将访问者从您的网站发送到 AMP 页面取决于您.卫报和大多数其他出版商设置它的方式是同时存在 AMP 和非 AMP 页面.如果您直接访问他们的网站,您将看到非 AMP 页面.因此,当从 Google 搜索结果轮播访问或直接通过 AMP URL 访问时,只会提供 AMP 页面.参考链接是为了让抓取工具能够知道是否存在 AMP/非 AMP 页面.

It is up to you if you want to send visitors to AMP pages or not from your website. The way The Guardian, and most other publishers, has set it up is that there is both an AMP and non-AMP page. If you visit their site directly, you will be served the non-AMP page. So only the AMP pages are served when accessed from the Google search results carousel or accessed directly by the AMP URL. The reference link is for crawlers to be able to know if there is an AMP/non-AMP page or not.

您可以执行《卫报》所做的一种基本方法是创建一个非 AMP 页面,其中 amphtml 链接引用指向 AMP 页面.IE.非 AMP 网页:

One basic way you could do what The Guardian has done is have a non-AMP page with the amphtml link reference pointing to the AMP page. ie. non-AMP Page:

mywebsite.abc/<slug to story>

AMP 页面:

mywebsite.abc/amp/<slug to story>

我希望这会有所帮助.我们为每个故事提供了一个 amphtml 参考链接,指向一个模板,该模板接受故事 ID 并返回故事的 AMP HTML 标记.

I hope this helps. What we have is for each story, there is an amphtml reference link pointing to a template that takes in the story ID and returns the AMP HTML markup for the story.