3

I have a site collection at the URL http://sharepointdev/discussionforum/GeneralDiscussion/, and inside the “Site Assets” folder, I defined a logo image “logo_CMYK.ico”. Now, inside my site collection master page, if I write the following :

<SharePoint:SPShortcutIcon runat="server" IconUrl="/discussionforum/GeneralDiscussion/SiteAssets/logo_CMYK.ico" />

The logo will show, but if I remove “/discussionforum/GeneralDiscussion” from the IconURL like so:

<SharePoint:SPShortcutIcon runat="server" IconUrl="/SiteAssets/logo_CMYK.ico" />

the icon will not be shown.

What is the best idea to define the source for my site collection assets? Thanks.

2
  • Why would you want to remove the /discussionforum/GeneralDiscussion ?
    – dzookatz
    Commented Sep 27, 2013 at 14:50
  • because on the production server we might want to define new managed path or new site collection names ?
    – John John
    Commented Sep 27, 2013 at 15:37

2 Answers 2

4

You can use relative paths as well. So, from a master page's position in your site hierarchy, the Site Assets folder would be at:

"../../SiteAssets/logo_CMYK.ico"
4
  • so the generated URL in this case will be "SERVERNAME/MANGE PATH NAME/SITE COLLECTION NAME/SiteAssets/logo_CMYK.ico" ?
    – John John
    Commented Sep 27, 2013 at 17:03
  • If it is placed on a page from the root site collection, then yes. Note that every subsite created also has its own 'Site Assets' library. So, if I use this relative path on a subsite that is 3 levels down in the hierarchy, then it will look in that particular subsite's SiteAssets directory.
    – tyshock
    Commented Sep 27, 2013 at 17:09
  • but if the subsite have 3 levels ,, then you should define "../../../SiteAssets/logo_CMYK.ico", is that right?
    – John John
    Commented Sep 27, 2013 at 17:20
  • 3
    If you want to always link to the SiteAssets folder of the Site Collection, regardless of whether you are on a subsite or not, then lgauds suggestion of the ~sitecollection url token is what you should use. If you want to always link to the SiteAssets folder of the current site (whether it be site collection or subsite), then the relative path solution is what you should use.
    – tyshock
    Commented Sep 27, 2013 at 19:54
6

Have you tried using the ~sitecollection url token? IconUrl="~sitecollection/SiteAssets/logo_CMYK.ico"

2
  • This does not works! Commented Feb 13, 2016 at 16:48
  • "~sitecollection" is handled as plainstring inSP2016. "IconUrl" is not renedering in the same way as scriptlink or other component inside Master page.
    – Mark L
    Commented Jul 29, 2019 at 1:34

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.