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

How to make a website on MODx AMP-page

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

Insert code:

$id_template = 4; 
//ID of the Template the Original. 
$id_template_url = 33; 
//ID of the Template AMP. $name_get ='amp'; 
//The query name is arbitrary (don't forget to change <link rel="amphtml" href="https://a-tum.biz/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;

3) robots.txt:

Allow: *?amp is a must.

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

Comment (0)

Comments are missing

Leave your comment

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