如何将现有页面转换为 AMP 兼容

How to convert existing pages AMP compliant

我计划让我的新闻页面符合 AMP 标准,我已经成功做到了。但是,我不得不删除一些自定义标签,例如 和 属性,这很好。

现在的问题是整个新闻页面显示在另一个不符合 AMP 标准的 HTML 页面中。

例如

<html ...>
    <head>...</head>
    <script>...</script>
    <body>...
        <div id="story">
            <AMP PAGE Content>
        </div>
    </body>
</html>

这里 story div 包含完整的 AMP 页面数据意味着在模板页面上显示的完整新闻报道。

现在问题是 story div 中的 AMP 页面成功完成了验证,但模板在验证时出错。

如果这个模板没有完成验证可以吗?

Google搜索或页面加载会有什么影响吗?

这个页面也使用了jquery,所以,如果我们使用jquery和AMP有什么解决办法吗?

如果这个模板没有完成验证可以吗?

  • 据我所知,这并不好,因为这可能真的会影响您的网页被发现。我认为如果你完成 validation of your AMP pages as this also confirms that your AMP document is discoverable.
  • 会更有好处

Google搜索或页面加载会有什么影响吗?

  • documentation所述,

    If the AMP validation service detects that there’s something wrong with your page, it won’t get discovered and distributed by third party websites and won’t appear in the Google AMP Cache. So not only would you lose the speed benefits of the cache, it’s likely that your page will not be seen in many places!

这个页面也使用了jquery,所以,如果我们用AMP使用jquery有什么解决办法吗?

  • 实际上,AMP 包含 three different parts:

    • AMP HTML is HTML with some restrictions for reliable performance and some extensions for building rich content beyond basic HTML.
    • The AMP JS library ensures the fast rendering of AMP HTML pages.
    • The Google AMP Cache can be used to serve cached AMP HTML pages.

    但是,另请注意,文档中提到 AMP 仅允许异步 JavaScript 以防止 JavaScript 延迟页面呈现,并且仅允许在 iframe 中使用第三方 JS。而且,如果有 JavaScripts 依赖于 jQuery,它们必须在 JavaScripts 之前加载。

希望对您有所帮助!