Change the default page when site is created

When you create a new publishing site in MOSS it automatically gets a default page created using the WelcomeLinks.aspx page layout. How can you change this behavior and have it automatically create a page based on a content type and page layout of your choice? Read on to find out how.

The Publishing template (as do all templates) have an ONET.XML file. In this file there is a modules section (as below), this defines the PublishingPageLayout and ContentType to be used when a site is created.


<Modules>
    <Module Name="Home" Url="$Resources:cmscore,List_Pages_UrlName;" Path="">
        <File Url="default.aspx" Type="GhostableInLibrary" Level="Draft" >
            <Property Name="Title" Value="$Resources:cmscore,IPPT_HomeWelcomePage_Title;" />
            <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/WelcomeLinks.aspx, ~SiteCollection/_catalogs/masterpage/WelcomeLinks.aspx" />
            <Property Name="ContentType" Value="$Resources:cmscore,contenttype_welcomepage_name;" />
        </File>
    </Module>
</Modules>

This could be changed to specify any default content type and page layout. The following shows how you might change it to a content type called MyContentType and a default page layout called MyPageLayout.aspx;


<Modules>
    <Module Name="Home" Url="$Resources:cmscore,List_Pages_UrlName;" Path="">
        <File Url="default.aspx" Type="GhostableInLibrary" Level="Draft" >
            <Property Name="Title" Value="$Resources:cmscore,IPPT_HomeWelcomePage_Title;" />
            <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx, ~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx" />
            <Property Name="ContentType" Value="MyContentType" />
            <Property Name="PublishingAssociatedContentType" Value=";#MyContentType;#0x010100C568…3A09F31E1FBA;#" />
        </File>
    </Module>
</Modules>

Note: The big number 0x010100C568…3A09F31E1FBA is obtained from the Url of the Content Type.

14 Responses to Change the default page when site is created

  1. CaitPSU says:

    How can you access the ONET.xml file? Can it be done through Sharepoint Designer? I’d rather not go into the file system – is there a way? Thanks

  2. Code Jedi says:

    I personnally am not concerned with accessing files in the file system and use Visual Studio to do such, although file explorer and notepad would suffice.

  3. anabhra says:

    I tried this without much luck. The ONET.XMl file that I modified was in this path

    C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates\PUBLISHING\XML.

    and this how I changed it (after creating a content type and page layout, both called CMSDefault) –

    Does this seem right?

    thanks,
    anabhra

  4. Code Jedi says:

    Did you perform an IISReset for the changes in the ONET.XML to be picked up. Also note the ONET.XML file is only used for the initial site creation and any changes made do not affect any existing sites already created from it.

  5. anabhra says:

    Thanks William. I did perform the IISReset.

    What I am trying to do is configure the default page for a group of child sites (publishing sites) under the parent publishing site that is the root application.

    So say http://severname:9001 is the application that I create as a publishing site. What I want is a default page for all 1st level children sites (http://server:9001/Media/*) and another default page for 2nd level children sites (http://server:9001/Media/WorldNews/*).

    Can this be done?

    Thanks,
    anabhra

  6. Code Jedi says:

    The only reason for setting the default page of a site template would be to aid the site creators by having the required default page automatically created at site creation. What you are suggesting could be achived out of the box just by creating a page based on the appropriate content type/page layout and then setting it as the Welcome page for that site.

  7. anabhra says:

    Yes, you are right.

    However, I have to create about eight 1st level sites and about 50 2nd level sites. A templated way to create them would come handy. Also, I have to replicate this effort accross 8 variation sites.

    Can’t I save my 1st level or 2nd levelsub site as a template and reuse?

    thanks,
    anabhra

  8. Sezai says:

    I too have been having problems getting this working, i think I finally have it sussed.

    Check out this blog post :

    http://katriendg.com/aboutdotnet/2007-5-1-publishing-web-syntax-onet-xml.aspx

    It states you need to make use of a ‘ContentTypeBinding’ feature so on creation of a new sub-site your custom content type is added to the Pages document library, so that the welcome page IS created correctly with your custom content type.

    Otherwise the correct page layout is used, but if you switch to ‘Edit’ mode on the new welcome page any field controls bound to new *custom* fields won’t render because the actual content type used for the page is ‘Page’ and not your custom content type.

  9. Deon says:

    Wow!! It’s getting better and better.,

  10. Yair says:

    Is this supported by MS?

  11. Vivan says:

    Great page layout 🙂

  12. Boyce says:

    Hello Dear, are you in fact visiting this web site daily, if so then you will definitely obtain good experience.

  13. I have read so many articles about the blogger lovers except this paragraph is actually a fastidious paragraph, keep
    it up.

Leave a reply to Boyce Cancel reply