Results templates determine how your query results are displayed in your search interface, depending on the selected result layout. They output a specific HTML representation for each raw JSON result item returned by the Coveo Search API.
Result templates are separated in result layouts, which determine the format in which your results are presented. Then, using a template engine, you can specify the way each result is displayed.
You are strongly encouraged to use HTML templates over Underscore templates for a variety of reasons.
|HTML Templates (recommended)||
For a result template to be understood as such, it needs to be a
script tag with an
id attribute and the
result-template CSS class.
Out of the Box Result Templates
When creating your search page using the Interface Editor, these result templates are automatically included in your page, inside the
div element that contains your
ResultList component or components, depending on whether you are using a single or mutliple result layouts.
Otherwise, you can include the default result templates by adding the correct script in the header of your page, after the
CoveoJsSearch.Lazy.js file, as follows:
templates.js file. Instead, create your own templates and upload them to your search page. By uploading your custom result templates inside the
ResultList component for their respective layout, they will be applied before the out of the box templates, even when the
templates.js file is included in your page.
Learn more about Result Templates and how to use and configure them.