Welcome to MSDN Blogs Sign in | Join | Help
Moving sites within Site Collection

The site templates under Publishing help organizations to manage the content for deleting, coping and moving sites within Site Collection and it isn't the same with other templates.

Site Content and Structure

For example if I have multiple Sites under the Collaboration template, so I will not be able to move the sites within Site Collection. So how do you get your sites to be moved to different locations within the site collection? Well it’s pretty straight forward. I had created my new custom web part to display the sub sites...and added bit of custom code to move the sites. All you have to do is just use the "ServerRelativeUrl". This avoids you to export and import sites

Dim siteCollection As New SPSite(http://Site)
Dim sourceSite As SPWeb = siteCollection.OpenWeb()
Dim sourceWeb As SPWeb = siteCollection.OpenWeb("/sites/Corporate/TeamSites/HR")
Dim destWeb As SPWeb = siteCollection.OpenWeb("/sites/Corporate/")
sourceWeb.ServerRelativeUrl = destWeb.ServerRelativeUrl + "/" + sourceWeb.Name
sourceWeb.Update()
destWeb.Update()

Other than moving the sites, you could try other snippets such as Copy the Site etc…

-Ravi Anguluri

Posted: Wednesday, March 19, 2008 6:24 PM by raviangu

Comments

vinay said:

Its working fine, but its not copying the documents under the document libray for old site to new site.

Can u pls suggest any other code, which can copy documents also.

Thanks in Advance

# April 11, 2008 2:18 AM

raviangu said:

The site reference is the same, this does not create a copy of the existing site. All we are doing is to change the relative path and this changes the site URL.

What you might have noticed is that the site that moved is still visible in the Navigation Pane on the top, this is because some properties related to Quick Launch under Site Settings need to be changed.

# April 11, 2008 1:37 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker