none
How to set a custom page as welcome page in SharePoint 2013 RRS feed

  • Question

  • Hi, 

    I have created custom site definition and I have to set custom page as Home page. Can anyone tell me how to proceed?

    Please note- I cannot keep custom page in any library like..Site Pages OR Pages, It should be on root.

    Thanks!!


    • Edited by asharma123 Monday, June 8, 2015 6:15 AM
    Monday, June 8, 2015 6:03 AM

Answers

  •  Using C# Object Model: 

    using (SPSite site = new SPSite("http://sharepoint.com")) 
       {
        using (SPWeb web = site.RootWeb) 
           {
            SPFolder rootFolder = web.RootFolder;
            rootFolder.WelcomePage = "Pages/HomePage.aspx";
            rootFolder.Update();
          }
       }

    Set Welcome Page in SharePoint Using PowerShell:

    $SiteUrl = "http://sharepoint.com"
    $Site = Get-SPWeb -identity $SiteUrl
    $RootFolder = $Site.RootFolder;
    $RootFolder.WelcomePage = "SitePages/HomePage.aspx";
    $RootFolder.Update();
    $Site.Dispose()



    Amit Kotha

    Monday, June 8, 2015 6:43 AM
  • Hi ,

    You can try below code .

    SPFile welcomeFile = newWeb.GetFile(newFilename); //newFilename is the page name 
    libraryFolder.WelcomePage = welcomeFile; //custom landing page    
    libraryFolder.Update();

    Mark this as answer if this is helpful.

    Thanks

    Bhism

    Monday, June 8, 2015 6:36 AM
  • this mean the URL:

    http://www.sharepointdiary.com/2012/06/how-to-set-welcome-page-programmatically.html

    :)


    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

    Monday, June 8, 2015 9:28 AM

All replies

  • If you want to set a Custom Page as a Home Page in a typical SharePoint Team site, you can simply do that by Opening the Page and selecting Page tab -> Make HomePage button to set this particular page as default Home Page for your site.
    SharePoint 2013 Set Home Page

    Option 2: Another option to set a Custom Page as Home Page in SharePoint 2013 Team site is by using SharePoint Designer 2013. If you have opened or created a Page in SharePoint Designer then you can right click on the page and select the option “Set as Home Page”to set it as a default home page of your SharePoint site.
    SharePoint 2013 Set as Home Page

    Option 3: If you are using the Publishing site (or site with publishing feature enabled), you can simply use the old “Welcome Page” link in the Site settings to set the URL of a page this is the desired home page for your SharePoint site.

    • Edited by Amit Kotha Monday, June 8, 2015 6:16 AM
    Monday, June 8, 2015 6:16 AM
  • Thanks Amit.

    I need to set it programatically and publishing feature is disabled.

    Monday, June 8, 2015 6:28 AM
  • Hi ,

    You can try below code .

    SPFile welcomeFile = newWeb.GetFile(newFilename); //newFilename is the page name 
    libraryFolder.WelcomePage = welcomeFile; //custom landing page    
    libraryFolder.Update();

    Mark this as answer if this is helpful.

    Thanks

    Bhism

    Monday, June 8, 2015 6:36 AM
  •  Using C# Object Model: 

    using (SPSite site = new SPSite("http://sharepoint.com")) 
       {
        using (SPWeb web = site.RootWeb) 
           {
            SPFolder rootFolder = web.RootFolder;
            rootFolder.WelcomePage = "Pages/HomePage.aspx";
            rootFolder.Update();
          }
       }

    Set Welcome Page in SharePoint Using PowerShell:

    $SiteUrl = "http://sharepoint.com"
    $Site = Get-SPWeb -identity $SiteUrl
    $RootFolder = $Site.RootFolder;
    $RootFolder.WelcomePage = "SitePages/HomePage.aspx";
    $RootFolder.Update();
    $Site.Dispose()



    Amit Kotha

    Monday, June 8, 2015 6:43 AM
  • this mean the URL:

    http://www.sharepointdiary.com/2012/06/how-to-set-welcome-page-programmatically.html

    :)


    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

    Monday, June 8, 2015 9:28 AM