SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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="" 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?

share|improve this question
up vote 14 down vote accepted

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.

share|improve this answer
Thanks worked like a charm. – Juergen Riemer Jan 8 '14 at 8:51

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

There is also the possibility to use a Custom action to load the library on any page using the ScriptSrc attribute as in

share|improve this answer
+1 for the explanations and useful links.. thanks – Juergen Riemer Jan 8 '14 at 8:52
happy to help, thank you! – Marius Constantinescu - MVP Jan 8 '14 at 9:40
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. – blachawk Jul 21 '14 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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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