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!
Comment | File | Size | Author |
---|---|---|---|
#6 | amp-add-pagemanager-support-2706745-6.patch | 1.02 KB | osopolar |
Comments
Comment #2
RainbowArrayYou 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.
Comment #3
RockSoup CreditAttribution: RockSoup commentedI 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.
Comment #4
RockSoup CreditAttribution: RockSoup commentedComment #5
osopolarThis should also be available for panels, shouldn't it?
Comment #6
osopolarPatch adds amp link-tag support for nodes handled by page-manager (and hence for panels).
Comment #7
Summit CreditAttribution: Summit commentedHi,
I think this is working great!
greetings, Martijn
Comment #8
Summit CreditAttribution: Summit commentedComment #10
mtiftCommitted and pushed to 7.x-1.x. Thanks all!
Comment #12
michalsen CreditAttribution: michalsen as a volunteer commentedI 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