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_linknginx
pagespeed EnableFilters insert_amp_link;IIS (pagespeed.config)
pagespeed EnableFilters insert_amp_linkpagespeed 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 theAmpLinkPatterndirective. 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_linkis not in CoreFilters, the default RewriteLevel; it runs only when you enable it by name withEnableFilters. - How do I enable insert_amp_link on Apache and nginx?
- Add
ModPagespeedEnableFilters insert_amp_linkon Apache orpagespeed EnableFilters insert_amp_link;on nginx. On IIS, addpagespeed EnableFilters insert_amp_linkto pagespeed.config.
Related filters
- add_base_tag — Add base tag
- add_head — Add head
- add_ids — Add IDs
- add_instrumentation — Add instrumentation
- collapse_whitespace — Collapse whitespace
- combine_heads — Combine heads
- compute_statistics — Compute HTML statistics
- convert_meta_tags — Convert meta tags
This page is drawn from the insert_amp_link entry on HTML filters. Every filter in one table: PageSpeed filters.