JSLink allows the following tokens to construct relative URL references.

~site—refers to the URL of the current Web site.
~sitecollection—refers to the URL of the parent site collection of the current Web site.
~layouts—refers to _layouts/15 with respect to the Web application.
~sitecollectionlayouts—refers to the layouts folder in thecurrent site collection (such as /sites/mysite/_layouts/15).
~sitelayouts—refers to the layouts folder in the current site (such as site/mysite/mysubsite/_layouts/15).

However I want to place my JSLink files more centrally like say in another site collection - Content Type Hub's Style Library to be exact.

Update for clarity

So instead of using the tokens I am using full URL to the Content Type Hub like this:

https://sptenant.sharepoint.com/sites/contentTypeHub/Style Library/JQuery/2.1.1/jquery-2.1.0.min.js|https://sptenant.sharepoint.com/sites/contentTypeHub//Style Library/JSLink Custom/EngineeringStatusReport.js

I have attempted this by putting the JSLink files into the Style Library of my Content Type Hub and then updated the Style Libraries permission to all everyone to read that Library.

I have not been able to make this work which forces me to copy the JSLink files to each Site Collection instead of just one single place.

Is this possible? Has anyone made this work?


  • I think the idle place will be inside the web application root sitecollection's catalog\displaytemplates folder – Amal Hashim Nov 26 '14 at 17:43
  • it can go there to but the idea is to put it where many site collections can access a single JSLink file – ChiliYago Nov 26 '14 at 17:55
  • I don't want to ask this but just wanted to make sure that you have published your JSLink files. :-) – Amit Tyagi Nov 26 '14 at 19:16
  • Roger that! All is published! – ChiliYago Nov 26 '14 at 20:48

There is no way to specify an absolute URL in the JSLink property. The JSLink string must start with ~. That being said, it would be nice if you could save all of the files in the Master Page Gallery of the web application, like Amal Hashim suggested. It would still provide a central location for storing files.

I was able to store my CSR files in the Master Page Gallery for my web application, but only in certain circumstances.

All of my site collections take the form, http://webApp.com/managedPath/siteCollection/.

For a ListFormWebPart (NewForm.aspx), I set JSLink to '~sitecollection/../../_catalogs/masterpage/Display Templates/xxx.js'. This worked great!

However, this doesn't work on regular views (XsltListViewWebPart). This is a big bummer because that's where I see us using JSLink the most. I'm still trying to work this out.

  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. – Waqas Sarwar MVP Dec 12 '14 at 5:06
  • I've added details that more specifically answer the question. – kduenke Dec 12 '14 at 17:21

To be quite honest, the URL tokens are unreliable and don't work when setting them on webparts all the time. I strongly suggest setting the JSLink at the view level and storing the file in the /_layouts folder (or a subfolder beneth). This is where the default one resides (clientrenderer.js). It will be accessible from any site collection here.

Run this powershell to attach it:

$web = Get-SPWeb http://<site>/<web>
$list = $web.Lists["YourList"];
$view = $list.Views["YourView"];
$view.JSLink = "/_layouts/15/customRenderer.js"
  • The tokens are working fine for me when entering them into the web part. In fact for this question I am not using tokens at all but full URL's to the Content Type Hub's Style Library. I am referencing the tokens in this post only for context. Thanks for the help though. – ChiliYago Nov 26 '14 at 18:17
  • aight, no prob. sry it didn't help, good luck – Michael Colbs Nov 26 '14 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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