Skip to main content

filter · HTML filters

Insert AMP link (insert_amp_link)

Category:
HTML
CoreFilters:
No
OptimizeForBandwidth:
No
Risk:
Not rated

Adds a <link rel="amphtml"> to <head> pointing at the page’s AMP version, built from the AmpLinkPattern directive. Use it when you publish AMP pages at a predictable URL pattern and want every canonical page to announce its AMP twin. Risk: a pattern that produces URLs that do not exist advertises broken AMP pages to crawlers.

When to use it

  • Not in CoreFilters: it runs only when you enable it by name.

Risks

The HTML filters page lists no specific risks for this filter. If a page misbehaves with it, DisableFilters insert_amp_link turns it off for the scope you set it in.

Configuration

Enable it in the module configuration, at server, virtual-host or location scope:

Apache

ModPagespeedEnableFilters insert_amp_link

nginx

pagespeed EnableFilters insert_amp_link;

IIS (pagespeed.config)

pagespeed EnableFilters insert_amp_link
pagespeed AmpLinkPattern "https://amp.example.com${url}";
pagespeed EnableFilters insert_amp_link;

Scoping, ForbidFilters and the thresholds filters read: Choosing filters .

Frequently asked questions

What does the insert_amp_link filter do?
Adds a <link rel="amphtml"> to <head> pointing at the page's AMP version, built from the AmpLinkPattern directive. Use it when you publish AMP pages at a predictable URL pattern and want every canonical page to announce its AMP twin. Risk: a pattern that produces URLs that do not exist advertises broken AMP pages to crawlers.
Is insert_amp_link enabled by default?
No. insert_amp_link is not in CoreFilters, the default RewriteLevel; it runs only when you enable it by name with EnableFilters.
How do I enable insert_amp_link on Apache and nginx?
Add ModPagespeedEnableFilters insert_amp_link on Apache or pagespeed EnableFilters insert_amp_link; on nginx. On IIS, add pagespeed EnableFilters insert_amp_link to pagespeed.config.

This page is drawn from the insert_amp_link entry on HTML filters. Every filter in one table: PageSpeed filters.

Search