Good day, I have the task to create custom search results page for existing list with thousand elements. The list has Enhanced Rich Text Field “DocFileLink”. The list elements have file links in this field (href html links). And I need to display this field in custom search results. I created new template for element displaying, managed properties. The list elements display correctly, but Enhanced Rich Text creates the problem because the html links convert to anchored text. How can I display Enhanced Rich Text in my custom Search Results template with html links?

My managed property has name “DocFileLinkMP”. Data Type:text

In my custom Search Results template

<mso:ManagedPropertyMapping msdt:dt="string">'Title':'Title',…….,'DocFileLink':'DocFileLinkMP'</mso:ManagedPropertyMapping>

I tried 1.

    var desc = $getItemValue(ctx, "DocFileLink");       
    _#= STSHtmlDecode(desc.value) =#_

It didn’t help, I see anchored text only in Search Results.

  1. I tried to use script to set html links to search results

    var linkString = ctx.CurrentItem.DocFileLinkMP; if($isEmptyString(linkString) == false) { var attachmentLinks = linkString.split(".pdf"); var numberOfLinks = attachmentLinks.length; var linkMarkup = ""; for(var i=0; i<numberOfLinks; i++) { var fullLink = attachmentLinks[i] + ".pdf"; linkMarkup = linkMarkup + "<a href='/Site/SiteAssets/SitePages/" + fullLink + "'>" + fullLink + "</a>"; } } _#-->


<div class="ms-rtestate-field">

It didn’t help too, because the file can be located in another folder, not in “/Site/SiteAssets/SitePages/”. And link anchored text doesn’t display the file folder, file name only. The link isn’t true for some list elements. I would be pleasure for any ideas.

  • Check this. let me know if it helps you. Commented Dec 17, 2019 at 7:47
  • I created the site column to Publishing HTML (DocFileLinkHTML). Search crawls are running fine. I added a reference to the managed property in the managed property mapping <mso:ManagedPropertyMapping msdt:dt="string">'Title':'Title' ... ,'DocFileLinkHTMLOWSHTML':'DocFileLinkHTMLOWSHTML'></mso:ManagedPropertyMapping> <td class="PageContentColumns" style="width:100px;"> #=ctx.CurrentItem.DocFileLinkHTMLOWSHTML=# </td> It didn't work
    – Anonymous
    Commented Dec 18, 2019 at 9:15
  • I understood. I created site column (DocFileLinkHTML) on my SubSite and it didn't work. I created site column to Publishing HTML (DocFileLinkHTMLtop) for top-level site, added it to my list. It works fine after full crawling. Thanks for your help.
    – Anonymous
    Commented Dec 20, 2019 at 9:47
  • Great, glad it worked for you. Commented Dec 20, 2019 at 9:56

1 Answer 1


Try creating a Publishing HTML field at site collection level and then use it in your display template like below:

Add a reference to the managed property(say ArticleContentOWSHTML) in the managed property mapping:

<mso:ManagedPropertyMapping msdt:dt="string">'Title':'Title' ... ,'ArticleContentOWSHTML':'ArticleContentOWSHTML'></mso:ManagedPropertyMapping>

and then reference the same in the display template body like:

   <td class=”PageContentColumns”>

See Rich Text Column content in Display template for Search Results webpart for more information.


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.