Documentation for AMP (Google) and MIP (Baidu).
This link tells search engines where to find the AMP/MIP version of the webpage.
<link href="https://example.com/some-webpage-with-amp" rel="amphtml">
<link href="https://example.com/some-webpage-with-mip" rel="miphtml">
The definition of the document type, to indicate which version of HTML the page is using. It should be HTML5, because older HTML doesn't support custom attributes.
<!DOCTYPE html>
<!DOCTYPE html>
The first tag in the document, having a specific attribute to indicate that the page is an AMP or MIP page.
<html amp>
OR
<html ⚡>
<html mip>
This element is mandiatory in both AMP and MIP.
<head>
<head>
The charset metadata should be present and should be UTF-8.
<meta charset="utf-8">
<meta charset="utf-8">
There should be a canonical link. This should point to the non-AMP or non-MIP page, or in case AMP/MIP is the only page, to itself.
<link href="https://example.com/some-webpage-without-amp" rel="canonical">
<link href="https://example.com/some-webpage-without-mip" rel="canonical">
There should be a viewport set. The width
value is mandatory and should be device-width
. Recommended it to add minimum-scale=1
and initial-scale=1
too.
<meta content="width=device-width" name="viewport">
<meta content="width=device-width" name="viewport">
The engine script should be present and should be asyncronically loaded.
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async src="https://c.mipcdn.com/static/v1/mip.js"></script>
OR
<script async src="https://c.mipcdn.com/static/v2/mip.js"></script>
AMP/MIP pages use boilerplate code to disable some CSS rendering until the right moment.
<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>
AND
<noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<link href="https://c.mipcdn.com/static/v1/mip.css" rel="stylesheet" type="text/css">
OR
<link href="https://c.mipcdn.com/static/v2/mip.css" rel="stylesheet" type="text/css">
This element is mandiatory in both AMP and MIP.
<body>
<body>
For loading custom elements that aren't loaded by default.
<script async custom-element="amp-gist" src="https://cdn.ampproject.org/v0/amp-gist-0.1.js"></script>
But src
is not mandatory:
<script async custom-element="amp-gist"></script>
<script src="https://c.mipcdn.com/static/v2/mip-mustache/mip-accordion.js"></script>
For loading custom templates that aren't loaded by default.
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
But src
is not mandatory:
<script async custom-template="amp-mustache"></script>
<script src="https://c.mipcdn.com/static/v2/mip-mustache/mip-mustache.js"></script>