I have installed the AMP module and configured a content type to have an AMP version for display at mydomain.com/blog/blog-title?amp and it works nicely. I have run into an issue with Google finding this URL. In reading the discovery documentation for AMP it states:

In some cases, you might want to have both a non-AMP and an AMP version of the same page, for example, a news article. Consider this: If Google Search finds the non-AMP version of that page, how does it know there’s an AMP version of it?

Linking pages with
<link>

In order to solve this problem, we add information about the AMP page to the non-AMP page and vice versa, in the form of <link> tags in the <head>.

I have used the metatag module to add to <head> of the AMP version of the node:

<link rel="canonical" href="https://mydomain.com/blog/blog-title">

But this still needs the non-AMP version of the node to have a link like the following added to the <head>:

<link rel="amphtml" href="https://mydomain.com/blog/blog-title?amp">

I am not sure if this should be switched to a feature request, or maybe a feature request for Metatag, or if there is a setting I missed, or if the expectation is that I will do this in a preprocess function or through some other means.

Really impressed with this module, nice work!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RockSoup created an issue. See original summary.

RainbowArray’s picture

You should not need to add a link element through metatag in order to achieve this. One of the key things this module does is to add a link element in head on the AMP pages to the non-AMP pages, and vice verse on the non-AMP pages add a link element that points to the AMP page. So what you're requesting should already exist. Note that this will only happen for content types that have the AMP view mode enabled.

RockSoup’s picture

I figured this was something the module would manage. I use panels to render the node in question here and I believe this is why the link tag was not being added to the head. I added a preprocess function and that did the trick.

RockSoup’s picture

Status: Active » Closed (works as designed)
osopolar’s picture

Title: Link tag in <head> to amp version of node » Add Panels support for link tag in <head> to amp version of node
Category: Support request » Feature request
Status: Closed (works as designed) » Active

This should also be available for panels, shouldn't it?

osopolar’s picture

Title: Add Panels support for link tag in <head> to amp version of node » Add page-manager support for link tag in <head> to amp version of node
Status: Active » Needs review
FileSize
1.02 KB

Patch adds amp link-tag support for nodes handled by page-manager (and hence for panels).

Summit’s picture

Hi,
I think this is working great!
greetings, Martijn

Summit’s picture

Status: Needs review » Reviewed & tested by the community

  • mtift committed 1f9724d on 7.x-1.x authored by osopolar
    Issue #2706745 by osopolar, RockSoup, Summit: Add page-manager support...
mtift’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 7.x-1.x. Thanks all!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

michalsen’s picture

I see this issue is closed, but am curious as to whether the rel="amphtml" link should be on the amp page itself. I would not have thought so, but not sure if it's something I mucked something up, or a bug I should submit a patch for....or it's supposed to be like that.
Thank you