01 June, 2012

Mystery of save site as template in SharePoint 2010

Whenever this word “mystery” comes into the picture then lot of questions arises as what exactly it is, How exactly it works, is it really same as SP2007 and so many things…
Today I want to share some issues that I have experienced and want to help you if you come across the same. By doing this, I want to save your time as well as the headache while troubleshooting the issue. Okay, let starts…
First of all-new things to highlight first:
SharePoint 2007 V/S SharePoint 2010
Site Templates
Solutions
/_catalogs/wt/Forms/Common.aspx
_catalogs/solutions/Forms/AllItems.aspx
saved as .STP
Saved as .WSP
No activation
Activation exist

In SharePoint 2010, when we save any site as template then it will get stored under solution gallery (site actions-site settings-Galleries-solutions)
Now suppose the requirement is:
You want to transfer any site/subsite from one site collection to another then how we will do/How exactly we will proceed ?
It’s very easy:
§  Open the source site on which you are working on/ that you want to transfer
§  Site actions
§  Site settings
§  Save site as template (site settings-site actions-Save site as Template)
§  It will provide you a box in which you provide the template name details
§  Once you click OK then it will save the template in solution gallery
§  Click on the template name and it will give you the option to save it to desktop
§  Now go to the destination site (site actions-site settings-galleries-solutions)
§  Upload the solution that you have saved in previous steps
§  That’s it-Done!!
Not able to see the uploaded site under custom tab
Here the mystery arises J
We have executed each and every step in correct order but still not able to see the uploaded template under custom tab/how we can create a subsite if we can see that saved template?
Don’t worry guys-here is the solution:
§  Open the site where you have uploaded that .WSP file/Template
§  Site actions
§  Site settings
§  Galleries
§  Solutions
§  Hover your mouse to the dropdown of that template
§  You will see the option of ‘Activate’

§  That’s it-as soon as you activates the solution, it will be ready to use and you can see the template name under ‘Custom Tab’.

Now suppose the requirement is:
After deploying the solution, I still cannot see the template when I create new site collection via Sharepoint Central Administration
Here is the answer for this: If you want to have the template available in the default templates list when creating a site collection it has to be installed as a farm solution.  That means creating a Web Template or a custom site definition.  You can take the sandbox solution template and import it into Visual Studio as the basis for a Web Template.
I think most of doubts has already been clear after reading the above mentioned information…but please don’t worry, if you have any queries/questions/confusion then please let me know. I would be more than happy to help you as well as resolves your issues.
Thank you

36 comments:

  1. Hi,

    I read some information at your website and thanks for sharing information with us.

    What I would like to know is how I can build a web template from scratch which has a custom masterpage and custom welcome page. I now have a custom masterpage and a custom page layout, but I don't know how to deploy them using a .wsp. I also don't know how to set my page layout page as a welcome page. Normally the default welcome page of a team site is sitepages/home.aspx, but I want it to be sitepages/mypage.aspx.

    Could you provide me with some more info?

    Appreciate it.

    ReplyDelete
  2. how to set my page layout page as a welcome page?-Its very easy.

    -Open your SharePoint site in SPD (SharePoint Designer)
    -copy your page in the site structure
    -Right click on the page
    -you will get the option "mark as default home page"

    2nd way:
    -Open your SharePoint site
    -site actions
    -site settings
    -welcome page
    -enter the page URL and that's it. you are done.

    Lets see which way would be more flexible for you.

    Another approach:

    What you can probably do is to import you saved site (the .wsp file) into Visual Studio. You will then need to add a new Feature and give the the FARM scope. Add the module or element that holds the WebTemplate feature that defines the site to this new Feature. Make sure you remove the module or element from the feature it was originally in. Repackage the whole thing and deploy the new .wsp file to Central Administration. Be aware that you will have to deploy it as a farm or full trust solution if you want to be able to create new site collections based on it without doing any extra work.

    for your reference: http://www.toddbaginski.com/blog/archive/2009/11/02/how-to-create-a-custom-site-definition-in-sharepoint-2010.aspx.aspx

    Please let me know in case of any further queries/questions, Thank you.

    ReplyDelete
  3. Hi Amol, I saved my template from the Production environment to my desktop and then uploaded to my development environment. It automatically activated the new solution in Dev in solution gallery. But when I try to create a site, it still takes the reference of the old site template. I had deactivated and deleted the old site template, removed it from my recycle bin as well as the Site collection recycle bin. Not sure why the old reference still there. It'll be helpful if you can let me know what else I'm missing. Thanks in advance

    ReplyDelete
    Replies
    1. Could you please tell me as what kind of old references are showing right now when you created that new site? Please mention in details

      also- I am pretty much that when we moved any template from one site collection to another then its ID will be change. If you wanna check this then its very simple.

      but you should know the ID of the previous template so that we can compare.

      let me know your thoughts and provide the requested information. Thank you.

      Delete
  4. Do you have any idea how to transfer a site template from http://sharepoint.abc.com/test/demo to http://sharepoint.abc.com/xyz/123

    ReplyDelete
  5. please refer the following details:

    Open the site: http://sharepoint.abc.com/test/demo
    site actions
    site settings
    Under Look and Feel
    save site as template
    it will ask you to save the site by name and template name
    after providing appropriate details, template will be successfully saved in site template gallery
    Now go inside this template gallery
    How to go inside this template gallery
    site actions
    site settings
    section name: Galleries
    template gallery
    you will find the template that we have saved in the above steps
    click on the template and it will ask you to save it to your desktop
    save it to your desktop

    Now open the other site collection: http://sharepoint.abc.com/xyz/123
    site action
    site settings
    galleries section
    upload the template that we have saved on desktop
    70% done
    now try to create the site as per your requirements and you will find that template under "creation of new site"

    please let me know in case of any queries/questions regarding the above mentioned steps, Thank you.

    ReplyDelete
  6. Thanks for the update so quickly Amol.I am not able to fine the Template gallery.All I see is

    Galleries
    •Site columns
    •Site content types
    •Web parts
    •List templates
    •Master pages
    •Themes
    •Solutions

    ReplyDelete
  7. when you saved the site as template then you gets the logon message "site has successfully saved"-On this page itself, there is one link to go inside the site template gallery.

    also- this option will be present on the site collection and not on the subsite.

    if you dont have a rights to that section then you will get 'access denied'

    ReplyDelete
  8. any results? are you able to move the site template from one site to another ?

    Let me know in case of any quries, Thank you

    ReplyDelete

  9. Hi Amol

    Everything just worked out fine.Thanks for your concern.Ur a gr8 help.

    ReplyDelete
  10. Thanks for the confirmation. Have a great time ahead

    ReplyDelete
  11. Hi Amol,

    just an enigma for you ;-).
    On my prod platform, one of my site collection, when creating a new site, is showing the list of available templates. I created 2 custom template which are displayed on these screen (and in the solutions gallery) but a third custom template appears in the list but NONE WSP is associated with him in the solutions gallery. it's a 'ghost template' ;-). This situation appeared when the administrator renamed/desactivated several times this template. I think Sharepoint must have lost this reference.
    So, do you have any ideas to remove this custom site template which does not appear in the solution gallery ?
    Thank you for your help
    a french guy
    Gerald

    ReplyDelete
  12. I have one action plan

    remove those both templates from the solution gallery, if you dont have a backup of those templates then save it first to your desktop and then remove it completely.

    once they will be completely removed then i would suggest you to check the number of templates under "create site" section.

    if you have any queries/questions regarding the above mentioned information then please let me know, Thank you.

    ReplyDelete
    Replies
    1. Ok, thank you for the tip, i will check later when less people are accessing this big site collection (60 GB..). I keep you informed. thank you
      Gerald

      Delete
    2. unfortunately, after deleting (from all levels of the recycle bin) the both custom site templates, the 'create site' screen is continuing to show the 'ghost' template..
      Gerald

      Delete
  13. no worries, keep me posted the end result, Thank you.

    ReplyDelete
    Replies
    1. and if i create a new site template with the same name, i get 2 templates with the same name in the 'create site' session. Strange...

      Delete
    2. I find the solution !!!
      I first use powershell to get the list of all available template on this site, and specifically information about the ghost template:
      $spweb=get-spweb "http://monsite"
      $spweb.GetAvailableWebTemplates(1033) | where {$_.Title -eq 'Ghost Template'} | select *.
      I get all information about this template but none about the feature.

      So, in the database, i request the list of solution and feature that mention 'Ghost Template', retrieve the Feature id and executes the powershell command : disable-spfeature ...
      And now, my site collection is no more haunted ;-)
      Gerald

      Delete
  14. Okay, Understood..

    I have two approaches to deal with this now:

    First: Code approach and second: GUI approach

    firstly we will concentrate on code approach

    can you please check this:
    In the root folder (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\1033)

    Here you will find a file called webtemp.xml this file controls the display of templates in SP.

    You will also see in this folder any custom Site Definitions that may have been created they will all have their own webtemp file, it will look somehting like webtemp*.xml * = the name of your new site def.

    Each site def has one or more site templates in it. Before you change any of these files (back them up first)

    2nd create a folder here and place the back up in the folder. Once you open the webtemp file you will see entries like this



    ....
    .....



    Secondly GUI approach

    If you enable the SharePoint Publishing Site Collection and Site features you will see an option under Look and Feel --> Page layouts and Site Templates.

    Here you can select to only make certain site templates available for users to create new sites within a site collection.

    This needs to be set up indivually for each of your site collections however so isn't ideal, but it is at least a clean, no-code way that doesn't require you to modify your webtemp file.

    Please keep me posted on results, Thanks for your patience

    ReplyDelete
    Replies
    1. regarding my last reply, i finally the solution to remove this ghost template
      But i would like to thank you for your support.
      Gerald

      Delete
  15. Excellent!! Thanks for sharing the solution.

    Let me know in case of any queries/questions in the future regarding any sp issue, Thanks again...

    ReplyDelete
  16. Hi,

    When create a site using my custom site template, getting 404 error. Home page also not setted in second site.

    ReplyDelete
    Replies
    1. Okay, try to browse the same site[which is giving problem] by using _layouts/settings.aspx (example- if the site URL is http://sharepoint2007/sites/Test/_layouts/settings.aspx)

      Please check the results and let me know. Depends on the result, we need to troubleshoot further.

      Delete
  17. Hello Amol,
    I am facing problem after creating site from site template. Site Controls are not coming up. Instead I am getting error message, web part/ control not able to upload. How to solve this problem.

    ReplyDelete
    Replies
    1. if the webparts are not loading/showing errors then there must be the following possibilities:

      - custom webparts in the form of content editor webparts (these webparts are using to contain code)

      - custom webparts designed by SharePoint Designer (SPD)

      - Custom webparts designed in Visual Studio

      what i can suggest is:
      => try to export those webparts and import on that site that you have created from saved template - please refer the following article for detailed instructions....
      http://sharepointknowledgebase.blogspot.in/2010/09/sp2010-exporting-and-importing-web.html

      => second thing- if its a content editor webpart then you can simply copy-paste the code, that's it

      => if its a webparts designed in SPD then you need to copy the code and replace the webpart guid with the one in which you are placing the code.

      Please let me know in case of any questions/queries. Thank you

      Delete
  18. Thanks for the reply Amol, I did try as you said imported the web part, When I try to add this web part to the page, I am getting error that " Unable to add selected web part(s)". This is a Smart Web Part. Any help in this regard. Really appreciate your comments.

    ReplyDelete
    Replies
    1. when you are getting that error then could you please check the logs and post here so that we can dig into?

      I am suspecting that a web part/user control smartpart is trying to load, but not marked it as a safe assembly? Also, if its not in the GAC, or the BIn directory with the correct trust level trust level set to either 'WSS_Medium' or to 'Full' allocated in the web.config for that site

      Delete
  19. I have created sites from a saved template. However, not all the items make it. I am missing a survey and the Quick Launch does not have the same items. Is this correctable at the template level or do I have to fix each and every site I create with this template? Thank you.

    ReplyDelete
    Replies
    1. with respect to quick launch, i am pretty much sure that you need to do it manually.

      Regarding Survey, this is a special list which does not get carry through after saved template.

      what i can suggest you is, in fact the best way- do it by means of export and import. easy way and everything will be replicated as it is. no manual work!

      if you wanna see what i am talking about, see this article:
      http://sharepointknowledgebase.blogspot.in/2012/06/sharepoint-2010-backuprestore-with.html

      from the above article, refer this section 'How to restore the subsite'

      please let me know in case of any further queries, thank you.

      Delete
  20. Hi Amol,

    I've same issue like Gerald had, But it is related to SP designer 2010 site template. removed both template from solutions and all recycle bin, but still available in 'Create Site'

    How can I search list of solution and feature in database?

    ReplyDelete
    Replies
    1. it is not recommended to modify the database directly, what i can suggest is- try to access the template/solutions/template gallery/recycle bin directly from the SharePoint Designer 2010. In other language, rather than accessing the site directly from the GUI, trace the path by means of designer and check the results.

      and then do iisreset

      let me know the results

      Delete
  21. This is easy word technical information about two SharePoint versions different and as an author you have write this solution surely helps you to over certain development problems regarding these versions.

    ReplyDelete
    Replies
    1. sure, will publish more articles on the same, Thanks

      Delete
  22. My partner and I absolutely love your blog and find the
    majority of your post's to be just what I'm looking for.

    Do you offer guest writers to write content available for
    you? I wouldn't mind writing a post or elaborating on a
    number of the subjects you write about here. Again, awesome
    website!

    Check out my homepage; website templates for arts and crafts

    ReplyDelete

Your feedback is always appreciated. I will try to reply to your queries as soon as possible- Amol Ghuge

Note: Only a member of this blog may post a comment.