I am trying to customize a Sharepoint 2013 team site.

I created a copy of seattle.master and set it as default master page via context menu.

I added my custom CSS within head tages like so:

<SharePoint:Scriptlink runat="server" Name="https://sharepoint.abc.org/sites/the_new_abc_portal/custom/jquery-1.10.2.min.js" Language="javascript" />


I added jQuery like so:

<SharePoint:ScriptLink language="javascript" name="/sites/the_new_abc_portal/custom/jquery-1.10.2.min.js" runat="server" Localizable="false" />

When I reload the page I get:

      <html><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"><meta name="Robots" content="NOINDEX " /></head><body></body>
      <script type="text/javascript">
                var gearPage = document.getElementById('GearPage');
                if(null != gearPage)
                document.title = "Error";

The link to jQuery is correct.

I now have a solution by which I simply add the normal script tag like so:

<script type="text/javascript" src="/sites/the_new_abc_portal/custom/jquery-1.10.2.min.js"></script>

Works like a charm.

Now my questions:

  1. Is there any objection against my "fix"

  2. Why doesn't it work in the first place?

3 Answers 3


The log file should get you the path that SharePoint unsuccessfully tries to resolve. Try adding "~sitecollection" first in the ScriptLink like:

<SharePoint:ScriptLink language="javascript" name="~sitecollection/custom/jquery-1.10.2.min.js" runat="server" Localizable="false" />

but this will only work inside the "the_new_osce_portal" Site collection.


In the 2nd statement you should have used the site collection specific TOKEN as in:

<SharePoint:Scriptlink runat="server" Name="~sitecollection/Style Library/[YOUR SITE]/PathToJqueryLib/jquery-1.10.2.min.js />

The issue with your 3rd (also known as Client-Side JavaScript library reference) is that such constructs do no recognize token-based constructs so that site collection relative path cannot be constructed dynamically. I would say is pure luck that the page at which you are most likely looking it just happens that it matches the URL to the library. As soon as you shall have a more deeper structure this won't work most likely.

Master page is a server side artifact, do try to use recommanded approach (use ScriptLink) to avoid future issues. Read more here http://tommdaly.wordpress.com/2010/12/16/scriptlink-vs-whats-the-difference/

There is also the possibility to use a Custom action to load the library on any page using the ScriptSrc attribute as in http://blog.lekman.com/2013/01/scriptlink-registration-in-sharepoint.html

  • C. Marius, is than way to apply this to a .htm master template in SharePoint 2013? I tried looking through the snippet gallery...but don't see anything that relates to adding external links...thanks for any advice.
    – klewis
    Commented Jul 21, 2014 at 12:14

Consider adding ScriptLinks as UserCustomAction instead of editing the masterpage. Like this:

/// <summary>
/// adds a scriptlink to the site 
/// </summary>
/// <param name="ctx"></param>
/// <param name="file"></param>
/// <param name="seq"></param>
private static void AddScriptLink(ClientContext ctx, string file, int seq)
 // Register Custom Action
 var customAction = ctx.Site.UserCustomActions.Add();
 customAction.Location = "ScriptLink";
 customAction.ScriptSrc = file;
 customAction.Sequence = seq;

 Console.WriteLine("ScriptLink Added : {0}", file);

here's where the sample comes from

See also MSDN on UserCustomActions

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.