SharePoint 2013 Developer Tips Series – Episode #1 Where is my /_layouts/?


The Problem

One of the biggest issues I faced when migrating code from my SharePoint 2010 solutions to SharePoint 2013 was the references that were made to images, css etc stored in the /_layouts/ directory.  In SharePoint 2010 when you added an item into this via visual studio (or even manually) the url for this would be for example: http://servername/_layouts/customfolder/images/myimage.png.

It would stand to reason that doing the exact same process for a SharePoint solution created in Visual Studio 2012 for SharePoint 2013 would be exactly the same right?  Sadly when migrating code to 2013, compiling and deploying all my layouts references appeared to be ok but for some reason would never work and would suffer from missing images, missing css styles etc.

The Solution

When I discovered the cause and the reason for the change things began to make complete sense.  SharePoint 2013 has a great new upgrade mechanism which enables customers to install SharePoint 2013, and then mount the content database from their SharePoint 2010 environment and run it as it always did in SharePoint 2013 without making the actual upgrade to 2013 until they are ready to.  Because of this ability to run both SharePoint 2010 and SharePoint 2013 natively on the same server hardware they had to ensure that it was backwards compatible.

So, how does this effect my /_layouts/ issue?  Any SharePoint solution compiled in a SharePoint 2010 solution which places assets into the /_layouts/ directory will be referenced as they always have been.  SharePoint 2013 solutions however although referenced in Visual Studio in exactly the same way, will now require references to be made as follows: http://servername/_layouts/15/customfolder/images/myimage.png.

The addition of the /15/ after the /_layouts/ is all that was required.  This caused my many headaches but thankfully once you know why, making the reference changes is easy.


I am the SharePoint Development Lead at ICS Solutions Ltd. As well as broad knowledge in SharePoint 2007, 2010 & 2013 my specialities lie with SharePoint Branding, WebPart Development and JQuery integration.

Got something to say? Go for it!