如何在Magento项目中集成Accelerated Mobile Pages

Dol*_*lly 5 php seo magento amp-html

我已经开始将AMP概念集成到我目前的Magento实时项目中.

我做过以下事情.

这里建议的www文件夹中的一个测试html文件,https://www.ampproject.org/docs/get_started/create/basic_markup.html这很有用.

我在magento项目中用1column.phtml做过,

<!DOCTYPE html>
<html amp lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
Run Code Online (Sandbox Code Playgroud)

在head.phtml中,添加第一行如下

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
<link rel="canonical" href="http://www.example.com" />
<script type="application/ld+json">
      {
        "@context": "http://schema.org",
        "@type": "NewsArticle",
        "headline": "Open-source framework for publishing content",
        "datePublished": "2015-10-07T12:02:41Z",
        "image": [
          "logo.jpg"
        ]
      }
    </script>
    <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
    <script async src="https://cdn.ampproject.org/v0.js"></script>
Run Code Online (Sandbox Code Playgroud)

我通过附加运行主页#development=1.并在控制台中获取错误如下:

TypeError: aa.Object.getOwnPropertyDescriptor(...) is not a non-null object
(var e in b)aa.Object.defineProperties?aa.Object.defineProperty(a,e,aa.Object.ge...
  validator.js (line 2, col 221)

ReferenceError: amp is not defined
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我解决这个问题.

提前致谢..

小智 1

尝试删除

xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>"
Run Code Online (Sandbox Code Playgroud)

前两行应该是这样的

<!doctype html>
<html amp lang="en">
Run Code Online (Sandbox Code Playgroud)