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.

  • Why would you want to remove the /discussionforum/GeneralDiscussion ? – dzookatz Sep 27 '13 at 14:50
  • because on the production server we might want to define new managed path or new site collection names ? – john Gu Sep 27 '13 at 15:37
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"
|improve this answer|||||
  • so the generated URL in this case will be "SERVERNAME/MANGE PATH NAME/SITE COLLECTION NAME/SiteAssets/logo_CMYK.ico" ? – john Gu Sep 27 '13 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 Sep 27 '13 at 17:09
  • but if the subsite have 3 levels ,, then you should define "../../../SiteAssets/logo_CMYK.ico", is that right? – john Gu Sep 27 '13 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 Sep 27 '13 at 19:54
6

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

|improve this answer|||||
  • This does not works! – Amit Bhagat Feb 13 '16 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 Jul 29 '19 at 1:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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