How to change the default home page in SharePoint 2007 or 2010

Below are four ways to set another page as your home page: (all four work for both 2007 and 2010)

  • From Site Settings (If the publishing features are enabled)
  • From SharePoint Designer
  • From code / API
  • From PowerShell

The first two can be used by Site Owners, the second two can only be used for developers and administrators.

Site Settings (if the publishing features are enabled for a site):

Site Actions, Site Settings, Welcome Page

SharePoint Designer:

Right-click the new page and click “Set as Home Page”.  (For SharePoint 2007 this only appears to work from SharePoint Designer if the file is in the root of the site. I.e. the same place as default.aspx.)

API:

C# and VB developers can use the SPFolder.WelcomePage property. See: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfolder.welcomepage.aspx

PowerShell:

for SharePoint 2010:

$site = Get-SPSite http://yourserver/sites/yoursite

$web = $site.RootWeb   (or $web = $site.OpenWeb(“yoursubsite”)

$folder = $web.RootFolder $folder.WelcomePage = “SitePages/home.aspx”

(or  $folder.WelcomePage = “default.aspx”)

(or  $folder.WelcomePage = “Shared%20Documents/mycustomwebpartpage.aspx”)

$folder.update()

$web.Dispose()

$site.Dispose()

for SharePoint 2007 (the first two lines are different):

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)

$site = New-Object Microsoft.SharePoint.SPSite(“http://yourserver/sites/yoursite“)

$web = $site.RootWeb

(or $web = $site.OpenWeb(“yoursubsite”)

$folder = $web.RootFolder $folder.WelcomePage = “SitePages/home.aspx”

(or  $folder.WelcomePage = “default.aspx”)

(or  $folder.WelcomePage = “Shared%20Documents/mycustomwebpartpage.aspx”)

$folder.update()

$web.Dispose() $site.Dispose()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: