To avoid adding some static HTML to my custom masterpage, and allow the end-user to easily change it by just changing an HTML file instead of the masterpage, I'm trying to embed a static ContentEditorWebPart to the masterpage.

I've had success by using something like:

<WebPartPages:ContentEditorWebPart webpart="true" runat="server" __WebPartId="{C0503828-714F-4DCA-BE3E-38CDA298D9BD}">
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
<Title>SharePoint Skins Footer</Title>
<ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">/SiteAssets/Test.html</ContentLink>
<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"></Content>

However, my issue is that the ContentLink "/SiteAssets/test.html" points to a relative Url. That's fine as long as the user hitting the site with my custom masterpage has at least read permissions on the root SPWeb to access the Site Assets DocLib and pull the test.html file from there.

What I am looking for is to use a relative Url as ContentLink to make the HTML file independent of the root SPWeb and allow each SPWeb to have its own.

So far, I tried to use "../SiteAssets/test.html", "SiteAssets/Test.html" and a couple of other combinations, but all failed under certain conditions, e.g. when hitting a page in "/_layouts" or "/Lists" or "/Forms" (well you get the point).

Since this has to work with SharePoint Foundation 2010/2013 and up in a hosted environment (like Office 365 or any other hosting company which does not use SharePoint Server as hosting platform) I am stuck with avoiding $SPUrl because it is only available in SharePoint Server.

Does anybody have an idea how to get this working inside a Foundation masterpage?

EDIT: And since it has to be accessibility compliant it has to work without relying on client-side JavaScript, so the trick referred at Get site url in ContentEditorWebPart content can't be used.


1 Answer 1


Have you tried using ~site and ~sitecollection tokens?

<ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">~site/SiteAssets/Test.html</ContentLink>
  • Excellent point! Will try and report back here.
    – Sig Weber
    Commented Mar 13, 2013 at 13:40
  • 1
    Been there, tried it. Unfortunately both fail with the usual "Cannot retrieve the URL specified in the Content Link property. For more assistance, contact your site administrator."
    – Sig Weber
    Commented Mar 13, 2013 at 14:11
  • 1
    Sorry didn't notice you are on SharePoint Foundation. The tokens are part of the Publishing dll which is not present in foundation. Commented Mar 13, 2013 at 15:48
  • Even in SharePoint Server 2010 this did not work for me. I think the ~site and ~siteCollection tokens are only parsed like that in a site definition XML file, not in a module element file.
    – Thriggle
    Commented Jun 29, 2015 at 21: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.