THE PROBLEM
AMP has matured and expanded dramatically since the module was first created. At that time AMP was expected to be used on a few "news" pages of a site, not as the primary content of the site. The assumption is that you would have a "real" page, the canonical page, and a stripped-down version as the AMP page. There were only a few AMP elements, a text element, an image element, a few others.
The current state of AMP is totally different. The library of elements has exploded to include advertising, analytics, numerous variations of image, video, and social posts. It's not just static content any more, it can be interactive content with personalization, sidebars, animation and more. It's not just for a few pages on the site any more, it could be for any page on the site. In fact, Google recommends using AMP for landing pages so your landing pages load fast. Some publishers are creating sites that are AMP-only, where the AMP page IS the canonical page and there is no other version. There are even more things coming, like AMP stories and AMP email.
The current module is not well-equipped for this new world. It handles the original cases but not much more. We need a complete rethinking of the code and architecture. At the same time, there are sites using the current module who may not want or need anything more than they now have. So we need to be conscious about not breaking backwards compatibility.
AMP requires Schema.org metadata be represented in the head of the document as JSON-LD. The AMP module provides a page where some very simple Schema.org elements can be configured. It's not extensible and it only appears on AMP pages and nowhere else. The code that creates this simple implementation is extensive, representing perhaps one-third of the code in this module. This code also represents a significant number of the issues and support requests on the AMP module.
The Schema.org Metatag module now provides a flexible and extensible way to display Schema.org metadata on every page using JSON-LD. But the AMP module currently won't support it and will strip it out.
ROADMAP
Here is my suggested roadmap. Create two new branches of the module as follows:
8.1 - the current branch is to be deprecated once users have a chance to upgrade.
8.2 - the same as 8.1, but remove all the code related to Schema.org metadata and ask users to use the Schema.org Metatag module to configure JSON-LD for their sites. Since this breaks backward compatibility, it needs to be a new branch. The codebase will be much smaller with all that code removed and hopefully easier to maintain. It should be stable enough for existing sites to continue to rely on.
8.3 - a branch to re-architect the AMP module to support things like AMP landing pages, AMP-only sites, and new interactive AMP elements.
PHASE 1
- Create the new branches and update documentation about the way this works and the path forward.
- Remove all the code related to creating and maintaining the JSON-LD metadata.
- Close all issues and bugs related to the way the metadata works and point users to the Schema.org Metatag module as a better solution.
- Fix critical bugs in the 8.2 branch, but add no new features.
PHASE 2
Start a new 8.3 branch. Rethink the architecture and rebuild it from scratch. Some initial ideas:
- Create a way to use AMP on landing pages and the home page.
- An AMP-only site won't need all the code that negotiates between the AMP and non-AMP version of a page. Move all that code to an optional module.
- Leave the AMP module mostly as a module that defines the APIs and provides core functionality needed for any use case.
- Create re-usable base classes, services, and traits for AMP formatters, to ease the process of creating formatters for the many new elements.
- Explore ways to make existing themes work with AMP without whole-scale rewrites. For instance, create a way to automatically write all css into a style tag instead of as links to avoid the need to hard-wire the css into the theme.
- Think about how to support something like AMP Stories or AMP Email.
Code optimization
- #2957524: Remove metadata handling, rely on Schema.org Metatag module - Remove metadata handling and use Schema.org Metatag instead.
- #2963387: AMP Context rework - context based on active theme - Loading a node every time AMP context is checked is too processor-intensive, most of the time we can just check the theme.
- #2759363: Reduce duplication in AmpHtmlResponseAttachmentsProcessor - Use decorators for service overrides instead of forking the original code.
- #2966168: Make sure that route object exists - Re-work the AMP context logic to make it easier to follow.
- #2962305: Lullabot AMP library Validate Generator needs update - AMP library is out of date.
- #2970810: Move Power User mode to separate module - Move the Power User mode to a separate module since it is currently broken, you can create valid AMP pages without it.
- #2970814: Change 'warnfix' to 'development' - Switch 'warnfix' to 'development' for so all debugging happens on same path.
- #3007403: Simplify AMP text formatters - Simplify text formatters, avoid extra level of processing of AMP Processed Text.
- #3007750: Make compatible with Big Pipe - Make AMP compatible with Big Pipe.
- #2962305: Lullabot AMP library Validate Generator needs update - The AMP library is outdated and was stripping out things it shouldn't. Did not get the library updated but added a subclass that allows us to identify tags that should not be stripped out and we can add to that list as we find problems.
New features in AMP module
- #2961697: Rework formatters - Create a re-usable AMP form trait for elements that are in many components, Add an image formatter and views style for AMP-CAROUSEL.
- #2963536: Make it possible to render css inline - Use Drupal's normal css handling to render css inline, for less confusion and so it's easier to create an AMP theme as a sub-theme of the normal theme, or even create an AMP theme for an AMP-only site.
- #2970858: Add an AMP System Branding Block - Add a new AMP system branding block that allows the user to input the logo width and height.
- #2972508: Add amp-sidebar and AMP Toolbar module to use it - Add an amp-sidebar theme, add AMP Toolbar module that moves the toolbar to a sidebar, partly to illustrate how to use it.
- #2973365: Add amp-social-share and social post (for amp-facebook, amp-twitter, etc.) - Add amp-social-share, amp-facebook, amp-twitter, amp-instagram, amp-pinterest.
- #2975775: Add AMP Consent for GDPR compliance - Add AMP Consent to get GDPR consent, and apply it to other components, like analytics.
- #3008278: Bring back whole page conversion - Bring back whole page conversion. Added a new hook, hook_amp_rules_alter(), which makes it possible to add/update rules that the converter uses. Converts the
<body></body>part of the page only, relies on Drupal's theme system for<head></head>.
New features in AMP theme
- #2967936: Start making the AMP theme more "normal", add sidebar, use libraries - Rework the AMP theme to use the CSS libraries system, now that css can be written into the page. Put toolbar and menu into AMP-sidebar sections. Remove javascript libraries using libraries-override instead of removing all javascript.
- #2961704: Use Drupal's library system to add AMP js to the page - Rework the AMP theme to use the JS libraries system instead of hard-coding js in the template.
- #2970858: Add an AMP System Branding Block - Remove the code trying to determine the logo size for the branding block, use the AMP branding block instead.
- #2970915: Add AMP Bartik theme - Add a new AMP Bartik theme to show how you can create an AMP theme as a subtheme of your normal theme.
Comments
Comment #2
karens commentedComment #3
karens commentedComment #4
karens commentedComment #5
karens commentedComment #6
karens commentedComment #7
karens commentedComment #8
karens commentedComment #9
karens commentedComment #10
sarathkmWhat about updating Lullabot AMP library validate-generator.php and its associate files.
Some stuff not working as it does not validate new stuffs in amp pages which were introduced since its last release, like amp-sidebar multiple declaration on same page removes duplication on same page by lullabot amp library.
Will amp 8.x-3.x also allows support for implementation of PWA in AMP?
Comment #11
karens commentedComment #12
karens commentedComment #13
karens commentedComment #14
karens commentedComment #15
karens commentedComment #16
karens commentedComment #17
karens commentedComment #18
karens commentedComment #19
karens commentedComment #20
karens commentedComment #21
karens commentedComment #22
karens commentedRelated to #10, that is already on the list. I don't have the time or skills to do that so it won't happen unless someone steps up to do it. The library is adequate to convert the body field, just not to convert the whole page (which was called Power User mode). I've already moved the whole-page conversion into separate module that is marked as not recommended. It is possible to use this module without that, it just requires the themes to strip out libraries that would inject javascript, etc. If you use 8.3 with the updated 8.3 themes and without that non-recommended module, all the new AMP components should work.
Comment #23
karens commentedComment #24
karens commentedComment #25
karens commentedComment #26
karens commentedComment #27
karens commentedMost of the things in this roadmap have been addressed. The couple that are unfinished are in the issue queue and will be handled there. So I'm closing this issue.