Adding Google Custom Search to AMP Site

I have Google Custom Search Engine (GCSE) code:

  (function() {
    var cx = '008589157460623253837:mhsjluzrngo';
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = '' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);


However, my Accelerated Mobile Pages (AMP) site does not allow me to add JavaScript to it, and I do not see any AMP components that enable GCSE to be injected into an AMP site.

How can I get GCSE on my site without breaking AMP compliance?



source to share

3 answers

You are correct, this is not supported yet as it is not in the AMP component list . Try doing a feature request on their githubpage .



You can try putting this code on a separate page and then including that page in AMP through the component amp-iframe

. You will also have to comply with the restrictions described here:



Use AMP amp-form component and submit form to Google Custom Search

look at this tutorial



All Articles