Skip to main content
Trans Am

Todd Klindt's SharePoint Admin Blog

Go Search
Home
Blog
Netcast homepage
SharePoint Terminology Wiki
  

Todd Klindt's home page > Todd Klindt's SharePoint Admin Blog > Posts > Can’t use some site templates with STSADM
Can’t use some site templates with STSADM

I got a tweet this morning from Laura Rogers about STSADM. She wanted to know if a site template had to be added with "stsadm –o addtemplate" before you could use it with "stsadm –o createweb." I have to admit, I didn't know the answer off the top of my head. I could convince myself either way. I ended up having to test it before I came to a conclusion. Before I get to whether it works or not, some background on why it's even a question…

If you've been to any of my SharePoint admin sessions or classes you're familiar with me preaching that Site Collections are the administrative and security boundary in SharePoint. This means that a user given permissions to one Site Collection cannot automatically get into another Site Collection without being given permission to it as well. Site Collections also are boundaries for resources kept in Site Collection galleries, like web parts, content types and site templates. Because of this boundary it's possible for administrators in one Site Collection to create resources that are only visible in their Site Collection. How does one do that? First, we have to be clear about the terminology we're using, because it gets confusing here. First we have the Site Collection. That's the boundary, the bag. Then we have the things that go into Site Collections. Here's where it gets confusing. Sometimes the SharePoint interface calls those things Sites, and other times it calls those things Webs. They're the same thing. This blog will be particularly confusing because it's one instance where the name changes frequently. Assume if something is not called out as a Site Collection, it's a web. Back to the question, how does a Site Collection administrator add new Site (really web) templates to their Site Collection? They take an existing Site (still really a web) and mock it up the way they want it. Maybe they add some pages, drop some web parts on some pages, maybe even upload a document or two. Once they get it juuuuust right, they save that Site (did I mention these are webs?) as a Site (web) Template. When they do that it's added to the Site Collection's Site (web) Template gallery. From that point on, anyone in the Site Collection that has permissions to create a Site (web) in that Site Collection can use that new Site (web) template to do so. The beauty of this is that no one outside of that Site Collection can see that Site (web) template. If you go to Site Actions > Site Settings > Galleries > Site Template Gallery you can see the Site (web) templates that have been created.

That's all fine and dandy, but what if that Site (web) Template is so awesome that someone else wants to use it? SharePoint's got your back, and provides a way to share Site (web) templates. If you have a Site (web) Template in your Site (web) Template Gallery, hover over it. You'll see it's a hyperlink. If you click it, your browser will try to download an STP file. That STP file is a Site (still typing web here) TemPlate file. You can give that STP file to an administrator for another Site Collection. If they upload it to their Site (you guessed it, web) Template Gallery now they can use it too. Pretty nifty, eh? So far this setup is working pretty well. But what happens if you have hundreds, nay, thousands of Site Collections? This approach doesn't scale very well at all. Once again, the fine folks at Microsoft were thinking ahead and they provided a way for you to take that STP file and make it available to the entire Farm in one step. How do you accomplish such a Herculean task? I'm glad you ask. First you download that STP file. Then you give it to one of your Farm Administrators. They log into one of the SharePoint boxes and use the STSADM operation "addtemplate" to add your template to the farm. Now everyone will see it when they create a Site (stick with me here, web) in the interface. The bottom line is that SharePoint allows you to keep Site (web) Templates private to a Site Collection or make them available to the entire Farm, whichever suites your needs best.

Back to Laura's question. She wanted to know if she could specify a custom Site (thanks for sticking with me, web) Template if she was creating the web not through the UI, but with "stsadm –o createweb" (see, they call it 'web' here. I told you!). I know that when the Site (do I need to keep typing 'web' here) Template is created it's added to the Site Collection, so it's in the Content DB. In theory STSADM could look for the Site (yup, web) Templates the target Site Collection had when creating the web. On the other hand I knew that the "addtemplate" operation put them someplace else, and maybe that's the only place STSADM looked when executing "createweb." To solve this I tested it myself. I created a custom Site (almost finished here, web) Template and then tried to use it when creating another web in that Site Collection with "stsadm –o createweb." It failed. It said that was an invalid template named. Executing "stsadm –o enumtemplates" showed me what template names were valid. Of course mine was not in that list. Once I added my Site (last time, I promise, web) Template to the farm with "stsadm –o addtemplate" I could use it with the "createweb" operation.

I hope that all made sense. The fact that Microsoft chose to refer to these objects as "sites" in the UI most places and "webs" in other places makes this very difficult to explain. I hope it all made sense.

tk

Comments

Well done!  Thanks for hammering that point home

I think you covered the web/site conundrum just the right amount of times.  The first time I wanted to create a "web" with a "site" template via code I was scratching my head a little. 

As a matter of fact, I just covered that in a blog post - http://jeffreylangdon.com/2009/07/07/list-event-handler-child-site-creation/ - showing how you can create a site (web) via an event handler; the code outlines that the SPWeb object is used in concert with the .stp file (site template).

Gotta love MS sometimes.;)

~JL
at 7/10/2009 8:44 AM

Thanks

Great explanation on that. I do love how MS uses both sites and then webs and then back to sites as terms - ha!

Beth
at 7/10/2009 10:04 AM

Re: Thanks

I like to think of the whole web/site terminology as Microsoft's way of implementing an intelligence test. If you can figure this out, you can keep using SharePoint. If not, you probably give up in frustration and work on something less frustrating, like nuclear physics or brain surgery.

tk
Todd O. Klindt at 7/10/2009 10:11 AM

Site vs Web

This goes way back. It's left over from pre 2003 days. Left this way for backwards compatibility. :)

Paul Swider
at 7/10/2009 10:43 AM

Can use custom template without AddTemplate by hand

Todd,

   Laura and I continued part of this discussion via Twitter after your post.  It is possible to use a custom site (web) template with the "stsadm -o createweb" command without first performing the "stsadm -o addtemplate".  It may not be enterprise-worthy, but is possible.
   First add the template to the site collection gallery by uploading the .stp file as you mentioned above.  Then run "stsadm -o createweb" command without specifying a site template.  Now navigate to the newly create site (web) and you'll be presented with a selection choice for which site (web) template you'd like to apply.  Only templates available to that site collection will be available.  By default SharePoint only applied the blank site (web) template since you didn't specify one when creating.
   It's a little workaround, but if for some reason your admins have an issue about adding templates to the global gallery you can still use your local site (web) templates with a little work.
at 7/10/2009 11:58 AM

Re: Can use custom template without AddTemplate by hand

Interesting workaround. Why is it necessary though? If someone has the permissions to pick a template for a newly created web, couldn't they just create the web themselves in the UI and cut out the middle man?

tk
Todd O. Klindt at 7/10/2009 1:46 PM

Sub Sites too large for template

I have increased the size of our templates via stsadm to 495 mb and cannot save a 472 mb site as a template.  It errors that it is too large.  I can't use export/import because of the workflows do not restore.
at 7/22/2010 1:25 PM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Today's date *

Please enter today's date so I know you are a real person
Attachments