Loading component...

Published on April 5, 2024Reading time: 5 min read

How to Control the Content in Coveo's Excerpt Field

Mastering customization for better search results

Loading component...

Related Articles

SitecoreAI

Building Your API Driven Integration Ecosystem for Sitecore XM Cloud

Seamlessly connect your existing APIs to your Headless XM Cloud Frontend with Vercel & Fastify

July 27, 20251 min read
Blog Card Placeholder
Sitecore

Turning the Sitecore OOTB Column Splitter Compatible for Tailwind in an XM Cloud Project

Learn how to use OOTB Grid Components compatible for Tailwind CSS powered projects.

May 23, 20251 min read

Loading component...

Digital solutions

Learn how to maximize your investment in Sitecore by working with us.

AI solutions

Dominate your industry. Work with us to digitally transform your business.

Fishtank's proprietary project accelerator. Save time and money. Build what matters.

Utilities

Energy

Education

Healthcare

Manufacturing

Professional services

Financial services

Non-profits and associations

About FishtankThe PlaybookSitecore SnackContact us

Solutions

  • Digital solutions
  • AI solutions
  • TIDAL for XM Cloud

About

  • About Fishtank
  • The Playbook
  • Sitecore Snack
  • Contact us

Insights

Work

Industries

  • Utilities
  • Energy
  • Education
  • Healthcare
  • Manufacturing
  • Professional services
  • Financial services
  • Non-profits and associations

Start typing to search...

We were building a search interface for a client, who commented that they saw the title in the search results summaries.

Two expert articles displayed side by side, one on finance and one on AI.

This was happening because we were using Coveo’s excerpt field, which changes based on search terms used. If no search terms are used, the excerpt field will show the beginning of the page’s content. However, when the search contained key words, the summary would change to highlight the terms used in the content.

A couple reviewing finances on a laptop at home.

The client asked about using a predefined Sitecore field instead. We explained this can be done, but the functionality provided by the excerpt field would be lost.

There are pros and cons to Coveo’s excerpt field, and the decision to use it or pull text from a predefined field comes down to how much control the client wants.

If content authors value the ability to control the summary more than having the summary react to search queries, then using a static field over Coveo’s excerpt field is probably a better choice. However, if a client is comfortable with a more organic search interface, or doesn’t want to manage a summary field, Coveo’s excerpt field will provide both of those requirements.

If you’re planning on using the excerpt field, you’ll need to set up your Coveo source correctly. Otherwise you might see menu and footer content in your result summaries! Read on to learn how to implement the excerpt field, and omit unrelated content from showing up in the result summary.

What is Coveo’s Excerpt Field?

When we use a search engine, we typically see our search terms highlighted in the summary text.

 Google search results for 'cats with sunglasses'.

Coveo supports this functionality with it’s excerpt field. This isn’t a field you need to map, and it is available for every source. You won’t see this field in the content editor for an item because it is generated at query time.

The excerpt field is also preferrable over a plain text field (like a static summary or clarity copy field) because it doesn’t require a content author to manage it. It’s available once a query is executed.

How to Implement the Excerpt Field

The excerpt field can be used like any other field: by adding field="excerpt" as an attribute to the atomic element.

Atomic React Wrapper example:

<AtomicResultText field="excerpt" />

Atomic HTML example:

<atomic-result-text field="excerpt" />

When you try it out in a browser, you’ll get something like the image below.

Search results highlighting greenhouses and environmental policies. 

How Do I Stop Menu, Footer, and Unrelated Content From Showing in the Excerpt Field?

Without proper configuration of a source, the excerpt field could show undesired content, such as words from the menu, header and footer. To stop this from happening, select the Web or Sitemap source in Coveo, and click Edit.

Screenshot of Coveo's 'Edit' option for site content configuration. 

In the Edit page, click Web scraping and then click Edit with JSON

Coveo's interface showing web scraping and JSON editing options. 

👆 Note: you’ll also see an Add configuration button on the screen, we’ll come back to that later.

A configuration window will appear. From here, you can “exclude” certain elements from the indexed content. These elements can be referenced by CSS or XPATH (I recommend CSS because it’s easier to understand and manage).

Detailed view of a JSON configuration file for web scraping in Coveo. 

Make sure your path and type match what’s on your website. In this example, type CSS and path header matches <header>…</header> on a website. However if you have HTML markup like <div class="header">...</div> instead, you would change the configuration to be:

{
    "type": "CSS",
    "path": ".header"
}

I recommend using the Web Scraper Helper for Coveo Web Sources Extension to help you correctly find the paths you need. To get it working, I had to install the extension, restart Chrome, load a age to test against, then open up the developer tools. To the far right, the Web Scraper tab should appear.

Chrome developer tools with an active Coveo Web Scraper tab. 

Once you’re done entering your excluded content, click Done and Save and Rebuild.

Not Comfortable Editing the JSON Configuration File? Let Coveo Do It for You.

If you don’t want to edit the configuration file directly, go back to the web scraping page and click Add configuration.

Interface for adding new web scraping configurations in Coveo. 

A new window will appear. Click the Elements to exclude tab and you’ll see options to add the CSS or XPATH selectors in a form. This is a more user-friendly way to enter the excluded elements to the JSON configuration. Be sure to still check your paths/selectors! A rebuild will also be required for these changes to be applied to the indexed content.

Form for excluding elements in Coveo's web scraping configuration. 

For more information on CSS vs XPATH and Coveo’s web scraping configurations, check out their deep-dive article.



Related Links

  • Choosing Coveo Atomic or Headless
  • Setting Up Single Language Results in Coveo Atomic Facet Search

Solutions

  • Digital solutions
  • AI solutions

Brands

  • TIDAL for SitecoreAI
  • Sitecore Snack
  • The Playbook

Fishtank lore

  • Work
  • Insights
  • About us
  • Contact us

Industries

Utilities
Professional services
Energy
Financial services
Healthcare
Education
Non-profits and associations
Manufacturing
Utilities
Professional services
Energy
Financial services
Healthcare
Education
Non-profits and associations
Manufacturing

2025 @All Rights Reserved. Privacy Policy.

FISHTANK