I've been struggling with this for some time now. I need to add a relative path from top site: Currently I've tried at least 2 options but in each case the code gets appended by SPD with __designer:Preview ect. I found a blog but cant see how to rewrite : blog on issue I need to go to site collection level as I'm adding master page to sub-templates. Any help appreciated, I also think $SPUrl causing issues with templates.

<asp:Image ImageUrl="<% $SPUrl:~sitecollection/Style Library/Images/logo1.png %>" runat="server"/>

<img src="<asp:literal runat='server' Text='<%$SPUrl:~sitecollection/Style Library/Images/logo1.png%>'></asp:literal>" />

1 Answer 1


Try this:

<img src="/Style Library/Images/logo.jpg" />

See this for more info: How to use relative URL for image in Master Page?

  • That works but when I create sub-site from template the path is wrong. as now I need to reference the site collection. This is why I'm trying to reference site collection independently. Dec 4, 2014 at 13:11

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.