建立自訂搜尋網頁
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本頁內容適用於 Apigee 和 Apigee Hybrid。
查看
Apigee Edge 說明文件。
如要啟用入口網站中公開內容的搜尋功能,可以建立專屬搜尋頁面,並嵌入 Google 自訂搜尋引擎 (CSE)。


如要建立自訂搜尋頁面,請按照下列步驟操作:
- 發布入口網站內容。
建立 Google 程式化搜尋引擎:
- 前往 Google 搜尋設定頁面。
- 按一下「新增」,即可建立新的程式化搜尋引擎。
- 設定自訂搜尋引擎,並找出入口網站網域。
請參閱 Google 程式化搜尋說明中的「建立搜尋引擎」。自訂搜尋設定會傳回類似下列內容:
<script async src="https://cse.google.com/cse.js?cx=e13bcb52d46f04dfd"></script>
<div class="gcse-search"></div>
其中 cx=e13bcb52d46f04dfd
是 Google 搜尋引擎 ID。
在入口網站中新增下列自訂指令碼。請參閱「新增自訂指令碼」。
將 cx
變數設為 Google 搜尋引擎 ID,例如 e13bcb52d46f04dfd
,並將 path
值設為搜尋網頁網址,例如 /search
。
<script>
window.portal = {
pageEventListeners: {
onLoad: (path) => {
// Update with your search page URL
if (path === '/your-search-page-URL') {
// Add your Google search engine ID
var cx = 'your-search-engine-id';
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);
gcse.onload = function () {
var search = document.createElement('gcse:search');
// Note the element ID name
var searchBox = document.getElementById('search-box');
searchBox.appendChild(search);
};
}
}
}
};
</script>
在入口網站中建立新的搜尋頁面,然後按照「管理入口網站中的頁面」一文所述自訂頁面。
在您希望顯示 Google 搜尋框的位置,加入自訂指令碼中定義的自訂搜尋元素 ID (search-box
)。例如:
<div id="search-box"></div>
如「設定導覽」一文所述,將搜尋頁面新增至入口網站導覽。
發布搜尋頁面和導覽更新。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-09-11 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-11 (世界標準時間)。"],[],[],null,[]]