您可以在xhtml上构建AMP吗?

时间:2019-03-14 18:09:01

标签: html xhtml amp-html

我的公司的前端使用.xhtml文件格式,但是我们被迫将AMP添加到我们的静态页面中。在我的研究中,我没有发现任何可以使用.xhtml格式的内容,当我尝试使用AMP .xhtml页面部署网站时,出现以下错误:“错误解析/storeAmp.xhtml:跟踪错误[line:1]在根元素之前的文档中的标记必须格式正确。” 我使用的样板代码在我的本地环境中运行良好,所以我知道这不是代码。我不确定是什么原因导致了此问题,并且无法在AMP项目网站上找到任何内容。

注意:我曾尝试使用.xhtml和.html来构建页面,但是在测试环境中均无法使用。当我使用.html时,它仍会调用一个不存在的.xh​​tml页面。

我想念什么吗?有办法还是没有希望的努力?

这是我正在尝试的样板代码。

    <!doctype html>
<html amp>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1">
    <meta name="description" content="This is the AMP Boilerplate.">
    <link rel="preload" as="script" href="https://cdn.ampproject.org/v0.js">
    <link rel="preconnect dns-prefetch" href="https://fonts.gstatic.com/" crossorigin>
    <script async src="https://cdn.ampproject.org/v0.js"></script>
    <!-- Import other AMP Extensions here -->
    <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
    <style amp-custom>
    /* Add your styles here */
    </style>
    <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>

    <link rel="canonical" href="testsite.html">
    <title>My AMP Page</title>
  </head>
  <body>
    <h1>Hello World</h1>
  </body>
</html>

0 个答案:

没有答案
相关问题