amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Specify how AMP pages are supposed to be referenced/linked from the their canonical pages

Open jamesreggio opened this issue 11 years ago • 32 comments

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).

jamesreggio avatar Oct 07 '15 18:10 jamesreggio

Good point!

FWIW, the MIME type for AMP HTML documents is the same as all other HTML documents: text/html

jmadler avatar Oct 07 '15 20:10 jmadler

There is a mechanism: <link rel="amphtml" href="{amp version}">

I don't see it documented though.

Gregable avatar Oct 07 '15 22:10 Gregable

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.

dvoytenko avatar Oct 07 '15 22:10 dvoytenko

Ah, excellent. That answers my question.

I'll leave this issue open as a reminder that the documentation can/should be improved.

jamesreggio avatar Oct 07 '15 22:10 jamesreggio

Yes, please keep open. We will fix.

dvoytenko avatar Oct 07 '15 22:10 dvoytenko

Jordan, do you want to re-assign this one to me? I can make the docs better.

Meggin avatar Oct 07 '15 23:10 Meggin

Lets fix the spec first. Then the docs.

cramforce avatar Oct 07 '15 23:10 cramforce

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

kevinmarks avatar Oct 08 '15 22:10 kevinmarks

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 :)

cramforce avatar Oct 08 '15 22:10 cramforce

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"

adactio avatar Oct 08 '15 22:10 adactio

:+1: @adactio's suggestion.

veganstraightedge avatar Oct 11 '15 15:10 veganstraightedge

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.)

jamesreggio avatar Oct 11 '15 22:10 jamesreggio

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 avatar Oct 11 '15 22:10 cramforce

@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.

adactio avatar Oct 12 '15 00:10 adactio

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.

cramforce avatar Oct 12 '15 03:10 cramforce

@jamesreggio Agreed with @adactio this is atcually pretty common in the RSS world...

julien51 avatar Oct 12 '15 12:10 julien51

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>

julien51 avatar Oct 13 '15 17:10 julien51

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.

Gregable avatar Oct 13 '15 18:10 Gregable

From the perspective of parsing the canonical page to find an AMP version, would a <link> inserted via JavaScript be acceptable?

joshcp avatar Nov 12 '15 00:11 joshcp

@joshcp Very good question! Pinging @amplesample

cramforce avatar Nov 12 '15 01:11 cramforce