Search code examples
htmlspring-mvcthymeleafamp-html

Using Accelerated Mobile Pages (amp) in thymeleaf


I need to use AMP technology with specific pages in a (Spring MVC + thymeleaf) website, following the guides on Create Your First AMP Page

the validator shows many errors:

  • The attribute 'xmlns' may not appear in tag 'html ⚡ for top-level html.

  • The tag 'head > style[amp-boilerplate] - old variant' is deprecated - use 'head > style[amp-boilerplate]' instead.

  • The mandatory text (CDATA) inside tag 'head > style[amp-boilerplate] old variant' is missing or incorrect.

code :

<!doctype html>
<html amp xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/" lang="ar">
<head>
  <title>Some title</title>
  <meta charset="utf-8" />
  <meta content="IE=edge" http-equiv="X-UA-Compatible" />
  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
  <link rel="canonical" content="some-url-here" />
  <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>
  <script async="" src="https://cdn.ampproject.org/v0.js"></script>
</head>
<body>
content is here
</body>
</html>

any idea how to fix that?


Solution

  • I figured out that the best way is to implement a different, light way version of ur page

    for example: CNN has refereed to the amp version
    view the source of this page: http://edition.cnn.com/2017/01/31/politics/donald-trump-supreme-court-announcement/index.html

    and here is the amp version https://amp.cnn.com/cnn/2017/01/31/politics/donald-trump-supreme-court-announcement/index.html

    So, for me I'll implement a new page without using thymeleaf