Google AMP in Sitecore module is an open source project supporting the Google Accelerated Mobile Pages (AMP) integration with Sitecore. It employs the Google AMP publishing technology to create web pages in Sitecore that load instantly on mobile devices through a Google search what brings a great performance benefit to the end users and improves the page ranking factor.
The module covers the following aspects:
- AMP view of a Sitecore page is based on a dedicated AMP Layout with limited AMP HTML, JavaScript and CSS as per AMP HTML specification;
- Each AMP page has its unique URL as per AMP guidelines, for example, an "/amp/" suffix can be added to the standard page URL;
- Page content is shared between non-AMP and AMP views, so no changes to the ordinary content management process.
The fundamental design of this solution is based on the standard Sitecore pipeline principle and this implementation overrides three Sitecore pipelines:
- httpRequestBegin
- mvc.buildPageDefinition
- mvc.renderRendering
..\src\Project\MyProject\Resolvers\AmpItemResolver.cs
Checks whether it is an AMP request by "/amp/" URL suffix or not and, if a resolved item has an AMP view, sets an AMP flag to true.
..\src\Project\MyProject\Resolvers\AmpProcessXmlBasedLayoutDefinition.cs
Substitutes a normal Layout with the AMP one for AMP requests on the fly.
..\src\Project\MyProject\Pipelines\ApplyVaryByAmp.cs
Extends the standard Vary By Param cache option to support AMP view.
..\src\Project\MyProject\App_Config\Include\MyProject.Amp.config
AMP specific config consists of the above pipelines definition and AMP Layout Id.
ContentComponents project contains the content components supporting the AMP view:
- YouTubeVideo
- SocialLinks
- InlineImage
- BackgroundImageResponsive
- BackgroundVideo
For example ..\src\Feature\ContentComponents\Views\YouTubeVideo.cshtml
demonstrates how to render a YouTube video for AMP.
Check of the current context by Context.IsAmpRequest()
method will allow to adopt the already existing components for AMP view with minimal efforts.
All components have the embeded microdata to render a structured data in JSON format and help Google to understand the content of the page where they are placed on. Schema.NET version 3.6.0 package has been used for Schema.org objects in .NET classes.
Hope you found the above solution elegant and helpful, your contributions and suggestions will be very much appreciated. Please submit a pull request.
The Google AMP in Sitecore module is released under the MIT license what means that you can modify and use it how you want even for commercial use. Please give it a star if you like it and your experience was positive.