Geeks With Blogs
Points To Share Mostly SharePoint

Relative and absolute URLs in CEWP

Microsoft’s own explanation of the CEWP in:http://office.microsoft.com/en-us/sharepoint-server-help/content-editor-web-part-HA010024046.aspx includes the following caveat:

Note: If you enter a URL into the Content Editor Web Part as a relative link, the link converts to an absolute URL when the entry is saved. This automatic conversion can be an issue if you are deploying content from a staging environment to production, where absolute URLs reference the original server's name. To address this automatic conversion issue, you will need to edit the Content Editor Web Part on the production server and update the URLs manually.

Can anything be done about it? How about thinking out of the box? No it’s not the same as OOTB – requiring no coding. It is out of the box that we are usually stuck in by our common education, the blinders that society puts on our eyes. It ought to be named “out of the rut” or OOTR.

So here is the OOTR solution. Put the CEWP HTML in a text file, relative URL included and put it in a document library. Put the link to this text file in the CEWP. Now when you move from one environment to another, as long as the structures of the environments are the same – namely they have the same relative navigation – the conversion will be done without reediting the web parts.

This approach offers an additional advantage. When a specific CEWP is deployed in multiple pages, the HTML is kept in one location. Any future changes will be done ONCE in this central location rather than the painful and error prone approach of editing the CEWP in every page.

The long and the short of is: CEWP content belongs in a text file and kept in a SharePoint library! The CEWP itself will only have the link to this text file, and no HTML of its own!

That’s all folks

Posted on Tuesday, May 1, 2012 2:06 AM | Back to top


Comments on this post: Relative and absolute URLs in CEWP

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © PointsToShare | Powered by: GeeksWithBlogs.net