Search code examples
amp-html

Can the amphtml link tag use relative href instead of absolute?


Our cms hosts multiple domains and generally its much easier to use relative paths whenever possible. I'm just wondering if its ok to have something like: <link rel="amphtml" href="/path/to.amp.html" /> instead of an absolute http(s) url


Solution

  • Even if it happens to work, it is much better to use absolute links for this purpose because the document could appear in another context (e.g. a proxy) and then resolving the relative link could fail.

    The example provided in the spec is absolute: https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#amp-document-discovery