自訂搜尋結果摘要
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本頁說明如何為自己的網站自訂搜尋結果摘要。如要轉譯自訂程式碼片段,您必須在網頁中加入結構化資料。
- 總覽
- 使用程式化搜尋元素建立複合式搜尋結果
- 探索其他功能
總覽
程式化搜尋引擎會顯示「網頁摘要」,讓使用者能大致瞭解網頁內容,進而協助使用者找到正確的網頁。如要進一步瞭解摘要,請參閱這篇有關搜尋結果剖析的網站管理員中心網誌文章。如果您不喜歡由程式化搜尋引擎演算法建立的標準程式碼片段,您可以自行建立程式碼片段。您可以直接在摘要中展示重要資訊,例如圖片縮圖、摘要、日期、作者、評分和價格。如果在搜尋結果中提供關聯性最高的資訊,就能提高您網站中的網頁對使用者的吸引力。
下圖說明自訂搜尋結果中摘要的各種方式。
圖 1:包含評分、價格範圍和評論的結果程式碼片段。

圖 2:包含格式設定、連結、圖片和比較資訊的結果程式碼片段。

圖 3:包含文件類型、作者、網頁瀏覽和註解的結果程式碼片段。

圖 4:格式豐富的結果程式碼片段,提供多媒體存取權和按鈕 (「加到 CART」)。

返回頁首
使用程式化搜尋元素建立複合式搜尋結果
基本上,建立複合式搜尋結果的步驟如下:
- 在網頁中提供結構化資料。
當程式化搜尋引擎為網頁建立索引時,程式會辨識並保留中繼資料。
- 在程式化搜尋引擎的搜尋結果中擷取該結構化資料。
程式化搜尋引擎伺服器可傳回搜尋結果,以及 JSON 格式的結構化資料。
- 建立簡報圖層,將結構化資料轉換為格式化 HTML。
「呈現層」是一組程式碼 (例如 JavaScript、PHP、JSP 和 ASP),可將原始資料轉換為向使用者顯示的格式。如果是程式化搜尋引擎,您可以:
如要進一步瞭解結構化資料擷取功能,請參閱結構化資料頁面。如要進一步瞭解如何運用程式化搜尋元素建立顯示圖層,請參閱
程式化搜尋元素頁面。
返回頁首
探索其他功能
自訂程式碼片段也適用於其他程式化搜尋引擎功能:
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[[["\u003cp\u003eProgrammable Search Engine allows you to customize result snippets to showcase key information like images, summaries, and ratings, making your site's search results more compelling.\u003c/p\u003e\n"],["\u003cp\u003eTo create custom snippets, you need to add structured data to your webpages, which Programmable Search Engine uses to generate rich snippets.\u003c/p\u003e\n"],["\u003cp\u003eThe Programmable Search Element can be utilized to easily transform the structured data into formatted HTML for display in search results.\u003c/p\u003e\n"],["\u003cp\u003eYou can further enhance your search results by exploring features like Drilling Deeper into Search Results and Providing Structured Data.\u003c/p\u003e\n"]]],[],null,["# Customizing Results Snippets\n\nThis page describes how to customize the result snippets for your own website. To render your customized snippets, you must add structured data to your webpages.\n\n1. [Overview](#overview)\n2. [Creating Rich Snippets with the Programmable Search Element](#creating_snippets)\n3. [Exploring Other Features](#next)\n\nOverview\n--------\n\nProgrammable Search Engine helps users find the right page by showing them a snippet---a small sample of content that gives search users an idea of what's in the webpage. To learn more about snippets, see the Webmaster Central [blog post](http://googlewebmastercentral.blogspot.com/2007/11/anatomy-of-search-result.html) on the anatomy of a search result. If you do not like the standard snippets created by the Programmable Search Engine algorithm, you can create your own snippets. You can showcase key information---such as image thumbnails, summaries, dates, authorship, ratings, and prices---directly in your snippets. Having the most relevant information in your search results makes the webpages in your site more compelling to your users.\n\nThe following figures demonstrate various ways you can customize the snippets in your search results.\n\n**Figure 1:** Result snippet with rating, price range, and review.\n\n**Figure 2:** Result snippet with formatting, links, image, and comparative information.\n\n**Figure 3:** Result snippet that includes document types, authors, page views, and comments.\n\n**Figure 4:** Richly formatted result snippet that provides multimedia access and buttons (\"ADD TO CART\").\n\n[Back to top](#top)\n\nCreating Rich Snippets with the Programmable Search Element\n-----------------------------------------------------------\n\nEssentially, creating rich snippets involves the following steps:\n\n1. Provide [structured data](/custom-search/docs/structured_data) in your webpages.\n\n When Programmable Search Engine is indexing your webpages, it recognizes and preserves\n the metadata.\n2. Fetch that structured data in the search results for your Programmable Search Engine. The Programmable Search Engine server can return the search results, along with the\n structured data in JSON format.\n\n3. Create a presentation layer to transform the structured data into formatted HTML. A presentation layer is a set of code (such as JavaScript, PHP,\n JSP and ASP) that transforms the raw data into a format that is displayed\n to the user. In the case of Programmable Search Engine, you can:\n\n - Use the [Programmable Search Element](/custom-search/docs/element) to transform JSON output for presentation to the user.\n - Write your own custom presentation layer that transforms JSON data to HTML that is presented to the end user using Search Element [Callbacks](/custom-search/docs/element#search-time-callbacks)\n\n\nStructured data extraction is documented in more detail in the\n[Structured Data](/custom-search/docs/structured_data) page, and creating a presentation\nlayer with the Programmable Search Element is documented in more detail at the\n[Programmable Search Element](https://developers.google.com/custom-search/docs/element) page.\n\n[Back to top](#top)\n\nExploring Other Features\n------------------------\n\n\nCustom Snippets works well with several other Programmable Search Engine features:\n\n- If you want to learn more about changing the order of your results, see [Drilling Deeper into Search Results](/custom-search/docs/structured_search).\n- If you want to learn more about what structured data Google supports, see [Providing Structured Data](/custom-search/docs/structured_data).\n- If you want to learn more about the Programmable Search Element, see [Programmable Search Element documentation](https://developers.google.com/custom-search/docs/element)."]]