I'm creating a content editor web part that needs to point to the site collection root. Currently, for it's "Content Link" URL field, I have ../../SiteAssets/js/jquery-rotator/slider.txt but this is inconvenient because if I'm in a publishing page such as /Pages/MyFolder/page.aspx, the path will have to be changed.

Is there a way to provide a path that always points to the site collection root's SiteAssets folder? Thanks.

  • 1
    Since it's custom, can't you just use SPContent.Current.Site.RootWeb.Url + "/" + ContentLink?
    – user2536
    Commented Oct 21, 2011 at 8:01
  • Thanks, Ziga. Actually, it's the built-in CEWP, but I'm setting it up the way I want, exporting it, and then saving it to the Web Part Gallery.
    – Alex C
    Commented Oct 21, 2011 at 8:06
  • 1
    Try inserting this <% $SPUrl:~SiteCollection/ContentLink_Here %>
    – user2536
    Commented Oct 21, 2011 at 8:39
  • <% $SPUrl:~SiteCollection/ContentLink_Here %> will not work. THis is only avaialble in master pages. CEWP does not support this syntax.
    – Clem
    Commented Oct 2, 2013 at 11:15

1 Answer 1


None of the answers in the comments are correct. Correct answer : ~sitecollection/SiteAssets/js/jquery-rotator/slider.txt

Several comments :

  • You cannot point to something outside of your site collection.
  • There are other tokens, such as ~site . I'll let you people google them.
  • sharePoint does not like "..". It might remove them. Although in more recent versions it worked (provided you stay within the site col) and it's even necessary because in some fancy documents sets home pages, SharePoint considers the current subfolder's URL to be the current location. To see exactly what SharePoint considers the current location, click on "try link" and see what URL it builds in your brower's address bar.

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.