I am just messing around with default Grav set-up and thinking how can I add AMP (Accelerated Mobile Pages) to existing news site.
So I started off with a partial base-amp.html.twig that will be a boiler plate for all AMP pages.
The challenging part is I don’t know how can I “call” it to generate for me my AMP version of article if I want have my post just once and let Grav create AMP version.
@flaviocopes I just tested my system.pages.types and tried adding .rss and it gave me an error. When I add .amp, it loads default .html page? Do I am missing something?
You need to define amp in Media types so Grav knows the MIME type. Then you need to add amp to the system.pages.types, then provide appropriate .amp.twig templates to render.
@rhukster something still isn’t right. In my system/config/system.yamlfile I have addedamp` to the end:
pages:
types: [txt,xml,html,htm,json,rss,atom,amp] # list of valid page types
Now this still doesn’t work. I checked other page types and when I add for example .rss to the end of the link I am getting E_WARNING - array_merge(): Argument #1 is not an array in the browser. When I try to access link with .amp at the end, I can see my page source code, not the amp version of the page.
That sounds like it covers creating a template for amp page, but you also need to ensure the content is using the correct markup. I would like to see how https://github.com/Lullabot/amp-library could be integrated with Twig and Grav