Using Middleman and AMP Project.
- Targeted towards online publishing, but is suitable for any web content
- instant loading with pre-loading (actually pre-loading only the ATF content)
- AMP pages are cached by Google
- An AMP page contains a script that handles the page load
- self-validates and outputs to console (append
#development=1
to URL for debugging) - Carousels, lightboxes, YT videos, tweets, etc. - are all AMP extensions (e.g.
<amp-youtube>
), a special script has to be included for each- AMP creates a box that is filled with content when the extension loads
- e.g.
<img>
element has to become<amp-img>
, so AMP can decide what loads when - ATF content is prioritized- it has to have
width
andheight
inlined - can take a
srcset
instead ofsrc
(for responsive images) - add
layout="responsive"
to adapt size to viewport (while keeping the ratio based on the inlined dimensions) - resize is allowed if element is not in the viewport
- it has to have
- have to be inlined in
<style amp-custom>
tag, this is doneafter_build
(look inconfig.rb
) - external webfonts -
@import
is disallowed, use<link>
tag
- Non-AMP JS is not allowed at all. Either find (or create) an AMP component or don't use AMP.
- Declare if a page should be also built as AMP page in the frontmatter (by default, it's not)
- Custom helpers:
amp_img()
- in the non-AMP version, it will output a regular image tagis_amp()