Search code examples
amp-html

AMP Discovery by Injecting <link> on canonical with javascript


I am researching providing some AMP Pages for my eCommerce site. I do not think that the CMS vendor had the ability to add dynamic content to the , So i will have trouble getting the Amp pages discoverabel in this senerio.

I was hopping to Inject the Link

link rel="amphtml" as indicated on The Discovery Docs with JavaScript, but this Stackoverflow article of a few years ago indicates that google will not render the javascript and will not be able to dymamicly generate injected Head/link tag.

Is this still true. Any thoughts from the community on a possible solution.


Solution

  • I wanted to repose for internet posterity. At this time it is not possible to use JavaScript to dynamically inject (link rel="amphtml") to have your AMP content recognized by google.

    You will have to have enough control over your page that you have the ability to have the ink rel="amphtml" rendered inline with the initial server load.