Specify how AMP pages are supposed to be referenced/linked from the their canonical pages
It's possible that I've just missed this detail in the sea of documentation, but it seems to me that there's no clear way to signal the existence of an AMP page from a canonical/ordinary webpage.
The <link rel="canonical"> tag exists for an AMP page to reference its canonical page. How should the canonical page reference its AMP page?
This seems like an important feature for search-engine discovery and optimistic redirection to AMP pages on mobile browsers. I would expect a tag like <link rel="alternate" type="application/amp+html"> or similar to do the trick (though I'm not sure what the AMP MIME type is, if one has been established).
Good point!
FWIW, the MIME type for AMP HTML documents is the same as all other HTML documents: text/html
There is a mechanism:
<link rel="amphtml" href="{amp version}">
I don't see it documented though.
Here's this in many examples, but I don't see a MD for it. We should add.
The canonical document for this article should be linked, as above.
The canonical document should also have a corresponding <link> tag
within pointing at this AMP HTML file:
<link rel="amphtml" href="http://example.ampproject.org/article-metadata.amp.html" />
It is possible that this AMP HTML document is the canonical document
for this article, in which case, the canonical URL should point to this
document, and no "amphtml" link is required.
Ah, excellent. That answers my question.
I'll leave this issue open as a reminder that the documentation can/should be improved.
Yes, please keep open. We will fix.
Jordan, do you want to re-assign this one to me? I can make the docs better.
Lets fix the spec first. Then the docs.
rel="alternate" is more accurate; rel="alternate" type="text/html" media="handheld" is a noted example
http://microformats.org/wiki/rel-alternate#With_media
if you do want to create rel="amphtml" please use the registry here:
http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions
I'm kind of on the fence here. We'd been using amphtml but it is not impossible to change.
How would the rel=alternate look examle
type="text/html+amp" ?
Don't really want to introduce a new mime type :)
Rel values can be combined (space separated) so how about allowing both:
link rel="amphtml" href="/path/to/amp.html"
and
link rel="alternate amphtml" href="/path/to/amp.html"
:+1: @adactio's suggestion.
I'm actually somewhat opposed to the multiple rels approach recommended by @adactio, if only because I'd imagine a lot of parsers are not written to handle that case well. (I've never seen multiple rels used before in the wild.)
I wonder if there is any concrete benefit of rel=alternate? It seems any application that would prefer AMP HTML would need to have a clear notion of AMP anyway.
@cramforce It’s more for the other way around: aggregators gathering multiple alternates e.g. a JSON version, an RDF version, an AMP version.
@jamesreggio You have led a very sheltered existence. :-) Space separated rel values are very much the norm, and anyone writing a parser is aware of that.
Filed internal bug at Google to check on whether we support the space separated version for discovering AMP documents already.
Tagged this bug "discovery" for everyone else following along on spec changes related to finding AMP documents.
@jamesreggio Agreed with @adactio this is atcually pretty common in the RSS world...
And talking about RSS, it would be nice if one of the recommendations was to also include this <atom:link rel="amphtml" ... /> into the feed's entries (RSS or Atom) themselves to avoid fetching both the HTML and the AMP when trying to poll resources from a feed.
Something like this:
<item>
<title>AMPed up</title>
<link>https://adactio.com/journal/9646</link>
<atom:link href="https://adactio.com/journal/9646/amp" rel="amphtml" />
<description>
<![CDATA[
...
]]>
</description>
<pubDate>Sat, 10 Oct 2015 15:02:39 GMT</pubDate>
<guid>https://adactio.com/journal/9646</guid>
</item>
I don't know if we will accept the space separated version on a non-amp page referring to an amp page, but we don't validate space separated rel values in an AMP document currently, and we should.
From the perspective of parsing the canonical page to find an AMP version, would a <link> inserted via JavaScript be acceptable?
@joshcp Very good question! Pinging @amplesample