Check if it's an amp page in shortcodes

I am trying to write an image shortcode that checks if it’s an AMP page or not. What I was thinking was to get the .Permalink of the current page, split it and check for an amp in that slice, but .Parmalink doesn’t work in the shortcode, is there any other way to do this?

Update:

OutputFormats doesn’t work too

To get to the page’s fields from a shortode, you need to do .Page.Permalink etc.

Is that the only way to check it?

BTW .Page.Permalink shows http://localhost:1313/ instead of localhost:1313/amp/ in the AMP page

You currently need to provide “AMP specific” shortcodes to trigger rerender of the content files, e.g. “myshort.amp.html”.

hi, if is not possible to use the same shortcode for images in AMP render, means that I need a duplicate markdown content, is that true?

No, that is not true.

Shortcode with amp in it should resolve the problem. Example figure.amp.html, this overrides the one used for non-amp.

2 Likes

I’ve been searching for this all around while it was sitting here. Thanks :slight_smile: