Quick cheat sheet on the introduction of Google AMP pages on the website MODx

08 aug 2019 458
How to make a website on MODx AMP-page

1) Create a new plugin (at the OnLoadWebDocument event):

Insert code:

<?php
$id_template = 4; //ID of the Template the Original. 
$id_template_url = 33; //ID of the Template AMP.
$name_get ='amp'; //query Name anyone (remember to change <link rel="amphtml" href="https://a-tum.biz/blog/kak-sdelat-na-sajte-modx-amp-straniczyi.html?amp" />).

$id = $modx->resource->get('id');
$resource = $modx->getObject('modResource',$id);
$template = $modx->resource->template; 
if($template == $id_template && isset($_GET[$name_get])) {
 $modx->resource->set('template', $id_template_url);
} 
$modx->resource->cacheable = false;

2) Remove the duplicates and show that there is amp:

<link rel="amphtml" href="https://a-tum.biz/blog/kak-sdelat-na-sajte-modx-amp-straniczyi.html?amp" /> 
<link rel="canonical" href="https://a-tum.biz/blog/kak-sdelat-na-sajte-modx-amp-straniczyi.html" /> 

3) robots.txt:
 

Allow: *?amp – обязательно.

4) Create a page for the amp:
we will not rewrite here the manual for the AMP tags. In short, use standard Html, Css and Js.

But there are invalid tags, for example:

  • the img is not correct
  • amp-img – right.
<amp-img src="#" width="900" height="400" alt="#" class=""></a amp-img >

Some tags will be stripped as they are stored only in the google cache.

Useful links on the subject:

  1. https://search.google.com/test/amp - check the AMP page
  2. https://validator.ampproject.org/ - validator AMP
  3. https://amp.dev/ru/documentation/guides-and-tutorials/?format=websites> -documentation
Share this post

Comments ()

No comment

Leave your comment

    Want to get new knowledge and knowledge?Sign up for a useful newsletter!