The first attempt was a disaster and produced over 565 AMP pages with errors!!!
Most common problem was using an embedded img style (which satisfied Google Mobile Friendly Pages) :
<img style"max-width:888px; width:88%; margin:auto">
Also there were other problems in the common header, menu, content and footer files.
Fortunately it was quite easy to revert to the original setup which consisted of the PHP Framework including a header, imported database data for the content and a footer.
Further thought about separation of concerns produced the following:
Web-Page for testing:
- index-001.php
Include files:
- _heading-amp.php
- _header-amp-static.php
- _menu-top.php
- _content-to-test.php
To install and start testing your “Accelerated Mobile Pages:”
- copy and paste the contents of “index-001.php”
- copy and paste the contents of “_heading-amp.php”
- copy and paste the contents of “_header-amp-static.php”
- create your own “_menu-top.php”
- create your own “_content-to-test.php”
- create your own “_footer.php”
- save all files into a new directory
- browse to “index-001.php”
- validate with Chrome Browser CTRL-SHFT-i
Online Demo - Can also test AMP validation using Chrome Browser ONLY
There is a vast amount of information about Google’s AMP, far too much in fact
This simple demo is a start and ideal for PHP Frameworks and possibly some CMSs.
Source file: index-001.php
<?php // index-amp-test-page.php
declare(strict_types=1); // PHP 7 ONLY
error_reporting(-1);
ini_set('display_errors', 'true');
// function fred($val) {echo '<pre>', print_r($val, true), '</pre>';}
$title = 'My Second attempt at installing Google\'s Accelerated Mobile Pages';
$title = isset($title) ? $title : '!!! YES we have NO TITLE !!!';
$sp = '#';
$canonical = isset($canonical) ?: '/' .$_SERVER['REQUEST_URI'];
?><!DOCTYPE HTML>
<html amp lang="en">
<head>
<?php
// My ORIGINAL Header copied and renamed
// so I could easily rollback changes
if(1) {include '_header-amp.php';}
// new stuff from Google's head
if(1) {include '_header-amp-static.php';}
?>
</head>
<body>
<div class='hdg'>
<?php require '_menu-top.php';?>
</div>
<h3 class="cgr"> Chrome Validation: <i class="cgg">CTRL-SHFT-i</i> </h3>
<div class="w88 mga bdd p42 bgs">
<?php if(1) { echo nl2br( file_get_contents('_content-to-test.php') );} ?>
</div>
<div class="w88 mga bdd bgs">
Source file: <b> index-001.php </b>
<hr>
<?php if(1) {highlight_file(__FILE__);} ?>
</div>
<div class="w88 mga bdd bgs">
Source file: <b> _header-amp.php </b>
<hr>
<?php if(1) {highlight_file('_header-amp.php');} ?>
</div>
<div class="w88 mga bdd bgs">
Source file: <b> _header-amp-static.php </b>
<hr>
<?php if(1) {highlight_file('_header-amp-static.php');} ?>
<?php if(0) {include '_footer.php';} ?>
</div>
</body>
</html>
Source file: **_header-amp.php** ``` <?php // _header-amp.php
declare(strict_types=1); // PHP 7 ONLY
?>
<?=$title;?> /* body {background-color: lime;} */ ```Source file: **_header-amp-static.php** ``` <?php // _header-amp-static.php
declare(strict_types=1); // PHP 7 ONLY
?>
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}} body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}<br>
**Edit:**
I forgot to mention that using the following validation tools fails because of ***amp*** tags :frowning:
[W3.org HTML Validator](https://validator.w3.org/)
[W3.org CSS Validator](https://jigsaw.w3.org/css-validator/)
It is essential to validate using the Chrome Browser?
<br>