v0.1.0
0.1.0.0eZ Platform Bundle that provides Accelerated Mobile Pages (AMP) support
MIT
The Requires
by Jani Tarvainen
eZ Platform Bundle that provides Accelerated Mobile Pages (AMP) support
This is an extension to the eZ Platform CMS that provides Accelerated Mobile Pages (AMP) Support., (*1)
Accelerated Mobile Pages is an initiative from Google to speed up mobile browsing. AMP is an open standard based on HTML. It enforces performance by limiting functionality and includes remote caching from Google to allow quick embedded views to search results., (*2)
Given Google's continuing dominance search both publishers and CMS vendors need to take AMP into account. This bundle enables eZ Platform installations to have quick access to an AMP formatted version of content objects., (*3)
Installation is similar to most Symfony Bundles:, (*4)
composer require janit/ez-amp-bundle
This will download and install the package to your local environment form Packagist (ez-amp-bundle), (*5)
Open the Application Kernel and add the bundle:, (*6)
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Janit\EzAmpBundle\EzAmpBundle(), ); } // ... }
This will load and enable the eZ AMP Bundle in your installation when the application bootstraps., (*7)
Add the following to your app/config/routing.yml:, (*8)
ez_amp: resource: "@EzAmpBundle/Controller/" type: annotation prefix: /
This will load the routes that provide the custom AMP content generation., (*9)
To enable discovery, find your main layout template and enter the following snippet into the head
section:, (*10)
{% if content is defined %} <link rel="amphtml" href="{{ url('ez_amp', {'objectId': content.versionInfo.contentInfo.id }) }}" /> {% endif %} </head>
This will allow the automatic discovery of your AMP versions by robots., (*11)
Open your browser and navigate to:, (*12)
http://example.com/ez-amp/1
This should display a simple version of your front page, with all the fields looped., (*13)
After this verify your content pages' head section should contain a reference to the AMP version:, (*14)
<link rel="amphtml" href="http://example.com/ez-amp/1337" />
The AMP version should also contain a canonical link back to the main version of the site:, (*15)
<link rel="canonical" href="http://example.com/jared-leet-o" />
With these links in place search engine crawlers will now find the AMP versions of your content. If you did this in production then soon the Google mobile search results pages will start displaying links to your AMP versions., (*16)
Next if you have not yet done so, verify your site on Google Webmaster tools and follow the state of the AMP validation. One of the errors you may encounter is failing images, because AMP does not allow use of the standard HTML <img>
tag, but has it's own <amp-img>
tag instead:, (*17)
<amp-img src="/var/site/storage/images/8/8/2/0/288-8-eng-GB/blog3.jpg" alt="" width="1840" height="1232" layout="responsive"> </amp-img>
It is possible that in some cases this custom image tag template is not rendered. If this happens with regular templates or embedded templates, it's worth taking a look at competing field_templates
definitions in your bundles/configurations., (*18)
While this bundle aims to provide valid AMP output by default, it is very crude as it is. If you wish to use this version, you can use Symfony Bundle Inheritance to override the templates to have a more pleasing layout and likely extended features that your custom site will require., (*19)
There are quite a few more things that should be added to the bundle to make it feature complete, both on eZ Platform and AMP side, some of which are:, (*20)
This is nothing but a hobby project that is mostly an exercise. There may be updates or there may not be updates. There is no warranty whatsoever, but the code is made available under the MIT license so it is free for you to use and abuse., (*21)
Going forward from version 3.2 eZ Platform (Enterprise Edition) will be known as the Ibexa DXP technology that is the base for three products: Ibexa Content, Ibexa Experience and Ibexa Commerce. Instructions in this code should be relevant since Ibexa DXP is an evolution of eZ Platform, not a revolution. Learn more from the Ibexa DXP v3.2 launch post and the Ibexa developer portal., (*22)
eZ Platform Bundle that provides Accelerated Mobile Pages (AMP) support
MIT