6/13/2011

SharePoint: How to change the default home page

 

I frequently get questions on changing the home page or using another page as the home page:

  • Can I have three (or four or five or…) columns in the default home page?
  • Do I have to use the new wiki home page in my Team Site?
  • I want to test a new home page design, but I don’t want to lose the existing home page… (just in case you know…)
  • How can I use a page from my wiki library as my home page?

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.

 

Important note for all four methods:

Make sure all of your users have at least read access to the new home page, and if in a library that you have it checked in and published.

 

If the publishing features are enabled for a site then:

Site Actions, Site Settings, Welcome Page

(that was easy!)

2007:

image

2010:

image

 

From 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.)

image

 

Via the API:

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

 

Via 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()

.

19 comments:

Pawan said...

Great Stuff. I have done this before using Designer. but it is great to know other three options also.

Thanks for sharing.

Larry W. Virden said...

Mike, I so appreciate all your articles. I have a problem quite similar to this - I need to set the home page for a SP2007 wiki that had to be restored from backup. During the restore, the property that indicates the home.aspx should be displayed was either unset, or not set, or something.

Right now publishing features are not enabled, and probably won't be due to the production nature of the site.
SharePoint Designer 2007 does not show a set as Home Page menu item when I click on either the wiki or the wiki's home.aspx page.
I don't know how to write in c# or vb.
So that leaves the powershell. I don't know, for certain, that I can use it. But it appears, based on this article, to be my last chance.
So, if my wiki's address is
http://myhost/sites/site1/wiki%20name
with a home page of home.aspx, then I understand changing the spsite argument to http://myhost/sites/site1 but if I set the $folder.WelcomePage to wiki%20name/home.aspx , is that going to set things for the wiki, or for the entire site? I don't want to screw up the user's sharepoint site experimenting...

Anonymous said...

I have been looking for this info. Thank you very much for posting it.

El

Hardik Patel said...

This script is not working on sharepoint powershell 2010.

Mike Smith said...

Hardik,

> This script is not working on sharepoint powershell 2010

I will need more info to help.
Is there an error message?
What template is being used in your site?
Do you have server admin rights?
Can you post your script?

Mike

Mike Smith said...

Hardik,

There is no PowerShell 2010. Make sure you are using the "SharePoint 2010 Management Shell" and not just PowerShell 2.0. (You can use PowerShell 2.0 as long as you load the SharePoint module.)

Mike

Randall Arnold said...

This would be great, except I have no folder list in SharePoint Designer 2010, and the Welcome page option doesn't show under Look and Feel on the web admin page.

???

Mike Smith said...

Randall,

> I have no folder list in SharePoint Designer 2010

To see your folder list click the pushpin in the All Files item in the Site Objects pane.

If you don't have the All Files option then SharePoint Designer may be partially locked down by your administrators. Ask if this has been disabled: "Allow Site Owners and Designers to See the Hidden URL structure of their Web Site".

> Welcome page option doesn't show under Look and Feel

That is only available "If the publishing features are enabled".

Mike

Anonymous said...

Awesome DUDE thanks so much!

Anonymous said...

Thank you , it was helpful

Anonymous said...

i've already set up links from my home page to multiple sub-sites & workspaces; will i lose all those links if i change the default home page?

Mike Smith said...

> will i lose all those links
If your links are in Quick Launch, Top Link Bar or a Links List web part, then no.

Anonymous said...

I changed my welcome page to a new default page. However users are not connecting to it. I can connect but others with access to the site before the change are getting web page cannot be found. What am I doing wrong here?

Mike Smith said...

> However users are not connecting to it.

Are they typing in the root URL? Something like http://servername/sites/test. Or are they clicking a link from another site or maybe browser favoriate?

Anonymous said...

I emailed them the new link and they were unable to connect. I am wondering if the site DNS has anything to do with it? Does it need to propergate?

Mike Smith said...

DNS would only have to do with the server name (http://www.server.com).

Check to see if the page:
- is checked in
- is published as a major version
- has the correct permissions for the users

Mike

Matthew said...

Great, much clearer than others on this subject. Worth pointing out maybe that when doing the right-click "Set as Home Page" in SP Designer, that it very helpfully renames the existing home page from "default.aspx" to "default-old.aspx" then renames your new page to "default.aspx" - and you can just set it back again if you need to - so there's no need to worry about taking back ups, renaming manually etc. Whichever is the home page is always made clear by having the "House" icon as well, so no confusion is possible.

Anonymous said...

Thanks for the sharing the script. Could you please let me know if a site page needs to be reverted for multiple Site-collections & subsites, what parameters can be added to this script?

Khurram Jamshed said...

to anyone facing issue of site not view able to users after applying new home page - publish as major version all your images/css folders in master page gallery related to your home page.

Note to spammers...

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.