SharePoint 2013 Branding: Use a Favicon Stored in a Library

Let's see how we can update the favicon in the masterpage to use a file stored in a library.

This is the the line that sets a favicon in the masterpage:

<SharePoint:SPShortcutIcon runat="server" IconUrl="/_layouts/images/favicon.ico" />

Since the file is stored on the server's layouts folder it's not a problem to use a relative path, but if you're storing your favicon in a list, using a relative path or an absolute path might not be the best option depending on the architecture of your site collections.

We'll deploy the favicon to a library in the root site of the site collection. Then we use it like so:

<link rel='shortcut icon' runat='server' href='<%$SPUrl:~SiteCollection/Style Library/MyBranding/images/favicon.ico%>' />

This line should replace the first line of code I showed.

Dércia Silva
Posted by Dércia Silva on July 4, 2014

Related articles