I want to format the search result based on the list name.

For example: If data is coming from ListName1 then I want to change the item URL in the search result. For all other result, I don't want to do anything.

So I want to know How can I achieve this? Which file I should modify and How I can check for the list name?

2 Answers 2


Why do you want to change the item URL?

You can edit the search result web part to check which display template you're using. Then access Site Settings > Master pages and page layouts > Display Templates > Search, download the template, modify and re-upload it. After that, edit search result web part to use the custom template.

In the template, the item URL is controlled by "Path" property. You need to judge the current item Path and replace it.


SharePoint 2013 Customize Display Template for Content By Search Web Part (CSWP)

How to customize search results display template

  • I am using default search result page. i.e osssearchresults.aspx. So I cannot edit the page. I have developed custom Item view form. So I want that item should redirect to custom form instead of default form Dec 28, 2017 at 12:13
  • @AakashMorya you actually can do that - just set the global (SSA) result item types to your custom one.
    – Mx.
    Dec 28, 2017 at 14:23
  • Also, what if I need to do this on SP2013 Foundation? Can I do there? I don't think so.. Dec 29, 2017 at 6:16
  • osssearchresults.aspx use Control_SearchResults template to show search results. The Control_SearchResults template is different from other templates e.g. Item_Default template. It's hard to edit item URL in this template. I suggest you create a search center instead of site search. Dec 29, 2017 at 6:35

I would suggest you to create a custom display template using Item_default.html then use the ctx.CurrentItem.Path property to find out the list to which this item belongs. Please let me know if you need anymore details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.