If you set up a Google Custom Search for your website, you will get some JavaScript code. But Accelerated Mobile Pages (AMP) site does not allow to add JavaScript to AMP site.
TL;DR
- Find your
Search engine ID
from JavaScript code. - Use AMP
amp-form
Component, and submit the form to Google Custom Search. - valid your AMP page.
1. Search engine ID
When you get JavaScript code from Google Custom Search, you can find your engine ID.
<script>
(function() {
var cx = '005682938207833448670:tg4ixgq0iyi';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
The value of
cx
is yourengine ID
, the aboveengine ID
is
005682938207833448670:tg4ixgq0iyi
2. amp-form Component
Copy the following code, and paste it into <head>
section
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
Copy the following code, and paste it into <body>
section
<div>
<form method="GET" class="p2" action="https://www.google.com/cse" target="_top">
<div class="ampstart-input inline-block relative mb3">
<input name="cx" type="hidden" value="005682938207833448670:tg4ixgq0iyi" />
<input name="ie" type="hidden" value="UTF-8" />
<input type="search" placeholder="Search..." name="q" required>
<input type="submit" value="Go" class="search-links">
</div>
</form>
</div>
replace the
engine ID
(005682938207833448670:tg4ixgq0iyi
) into yours
3. AMP page valid
相关文章
注册谷歌账户时:此电话号码无法用于进行验证
谷歌旗下有很多实用的工具,除了外贸常用的 Gmail 邮箱,还有谷歌 SEO 经常用到的谷歌站长、谷歌分析、谷歌关键词规划师等工具。所以,申请注册一个谷歌账号对于外贸人或者谷歌 SEO 从业者来说,都是很有必要的。
谷歌悄悄在Chrome中添加了HEVC支持
在网站上没有任何公告或更新的情况下,Google 悄悄地启用了对 HEVC/H.265 视频内容的自适应流媒体的支持!因为 MPEG-LA 和 HEVC Advance 专利太黑,给谷歌和苹果报价太高,只能交钱才能使用。以至于 Chrome...
使用git commit --fixup修改之前的提交
使用git commit --amend可以简单的修改前一条记录,但是不能修改前面第 N 次提交记录,这个时候使用git commit --fixup可以修改前面的提交第 N 次记录。