How to reference your custom CSS within a Search Display Template

Display Templates are incredible powerful within SharePoint 2013. You can create a new one based on an existing display template. To change the look & feel you create your own CSS. To reference to this CSS file you have to add the following code under the <body> tag:

    <script>

        $includeCSS(this.url, “~sitecollection/Style Library/YourCSS.css”);

    </script>

 In some cases a script tag already exists referencing a JavaScript file, just add the CSS reference within this tag, no need to create a new one.

Hope this helps you save some time and create awesome display templates 🙂

Leave a reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.