If you simply copy a display template to a new item and try to make use of it, you will encounter an error such as the following:
Template '~sitecollection/_catalogs/masterpage/Display Templates/Search/Custom_Item_Picture.js' not found or has syntax errors. (LoadTemplate: ~sitecollection/_catalogs/masterpage/Display Templates/Search/Group_Default.js)
Here are some tips on how to work with these files. You can use the tool of your choice. I decided to use nothing but Notepad and a browser.
- Work with the UNC path to the site collection's master page gallery. Map a drive to it if you prefer. E.g. \\intranet.somewhere.com\sites\abc\_catalogs\masterpage.
- In Windows Explorer, copy the relevant existing display template (such as Item_Default.js) to an item of your own name. Alternatively work via the browser to download and then upload a copy.
- Navigate to the master page gallery in the browser and set the new item's properties to be precisely the same as the item you copied from.
- Open the new display template, from the UNC path or mapped drive, in an editor such as Notepad.
- Within the file content you will find several references to the file's own name (such as Item_Default). Replace these with references to your new file name. You can do a find-replace but be careful because at least one of the references excludes the '.js' extension - make sure you catch all of these occurrences.
- At this point you should save and test that everything is working by referencing your new template from an appropriate search artifact, such as a result type. If all is well, you can then start altering the details to display things differently.