Logo 
Search:

Sharepoint 2010 Articles

Submit Article
Home » Articles » Sharepoint 2010 » Development and ProgrammingRSS Feeds

How to Deploy a Site Taxonomy in SharePoint 2010

Posted By: Destin Joy     Category: Sharepoint 2010     Views: 5875

Sometimes we need to modify the out-of-the-box templates to deploy an entire site hierarchy based on the designed architecture. There situations that require a code-based approach to do this, many times we can simply create our site template modifications in SharePoint’s graphical user interface and then deploy the site hierarchy with a PowerShell script, avoiding the more complex development and code lifecycle issues.

In this article helps to accomplish the following tasks

  1. Create and configure a Web template in the SharePoint graphical user interface.
  2. Modify and deploy the template for global use on the farm.
  3. Create and execute a PowerShell script to deploy a hierarchy of sites.


Create and Configure a Web Template

  1. Go to your web application
  2. From the Site Actions menu, click New Site.
  3. Choose the Team Site template, fill in the site Title and URL and click Create.
  4. In your new site, in the left Quick Launch navigation, click Shared Documents.
  5. In the Ribbon, click the Library tab; then click the button labeled Library Settings.
  6. Click Version Settings.
  7. Change the Document Version Settings to Create Major and Minor (Draft) Versions.
  8. Set the Require Check Out setting to Yes.
  9. Click OK.
  10. In the left Quick Launch navigation, click Shared Documents.
  11. Upload a file or two to this library.
  12. Make other changes to list/library settings, and add other content to other places within the site.
  13. From the Site Actions menu, click Site Settings.
  14. In the Site Actions group, click Save Site as Template.
  15. Set the filename and template name to Demo, and ensure the Include Content box is checked.
  16. Click OK.
  17. When the template has been captured successfully, click the Solutions Gallery link that appears on the success confirmation page.
  18. Open another browser window and navigate to your Central Administration site. Click Create Site Collections under the Application Management group .In the Template Selection area, click through all the tabs. You notice that your Demo template is not listed and therefore not available for use outside the site collection in which it was created. The next section solves this issue.


Modify and Deploy a Web Template for Global Farm Use

The web template created above has been deployed to the site collection sandbox solution gallery. This means that it can now create new sites within that site collection only. But our aim is to build a hierarchy of sites in a new site collection, modify the web template in Visual Studio and deploy it to the farm.

  1. Navigate there by going to Site Settings (from the Site Actions menu) and then from the Galleries group, click Solutions.
  2. You should see the template that you created above. Click its name, and you will be prompted to download a .wsp file.
  3. Open Visual Studio by opening your Start Menu and selecting the Microsoft Visual Studio 2010 icon.
  4. From the Start Page in Visual Studio, on the left side click New Project.
  5. In the left list, expand the SharePoint node, and choose 2010.In the right list, choose the Import SharePoint Solution Package template. In the Name text box, type TemplateDemo as the name for your new Visual Studio Project. See the following screenshot for guidance.

alt text

  1. Click OK. In the SharePoint Customization Wizard that follows, ensure that the local debugging site is pointed at your local SharePoint URL and change the trust level for your solution to Deploy as a Farm Solution. Click Next.
  2. When prompted for the path to the existing solution package, use the Browse button to navigate to the WSP file we saved in step 1.Click next.
  3. Ensure that all items are selected for import; then click Finish.
  4. In the Solution Explorer ,find the four features that are labeled Feature1, Feature2, Feature3, and Feature4. (See the image on the right.) Right-click on each one and choose Rename. Rename them as follows:

alt text

  • Feature1 -> ListInstances
  • Feature2 -> Modules
  • Feature3 -> WebTemplate
  • Feature4 -> PropertyBag

    1. If the Properties window is not visible, turn it on by opening the View menu in the main toolbar, and choose Properties Window (toward the bottom).
    2. Expand the feature that is now labeled ListInstance, and double-click the ListInstances.feature node as shown here.

alt text

  1. In the Properties window, change the Is Hidden property to True, as shown in the screenshot to the right. Repeat this process for the Modules and PropertyBag features as well (but not the WebTemplate feature).

alt text

  1. Double-click the WebTemplate.feature file (as you have the others), but do not set it as hidden. Instead, find the scope setting, and change it from Site to Farm as shown in the following screenshot.

alt text

In the Properties window, find the Feature Id property and copy the GUID value (be sure to get all of it) and paste it into a Notepad document. You will need this later.

  1. Click the File menu, and choose Save All.
  2. In the Visual Studio Solution Explorer, right-click the project, and choose Package.

alt text

  1. Right-click again on the project, and choose Open Folder in Windows Explorer. In Explorer, navigate into the bin\Debug folder. Copy the TemplateDemo.wsp file from this folder to a location that has a shorter path, such as c:\Demo\ TemplateDemo .wsp.
  2. Close Visual Studio and open the SharePoint 2010 Management Shell from the Start Menu.
  3. Type in the following command to add your new solution to the farm: Add-SPSolution c:\Demo\ TemplateDemo.wsp
  4. Type in the following command to deploy your new solution globally in the farm: Install-SPSolution TemplateDemo.wsp –GACDeployment
  5. Close the SharePoint 2010 Management Shell, and open your Central Administration site in a browser.
  6. Click Create Site Collections under the Application Management group. In the Template Selection area, click the Custom tab, and notice that DemoTemplate now displays as a choice. You have now successfully made your web template available for global use!
    Use PowerShell to Deploy a Hierarchy of Sites

Our last task is to create a hierarchy of sites using the template we modified in step 2 and create a PowerShell script that we develop. Following is the site taxonomy that we need to produce:

alt text

Normally, you would create this type of hierarchy at the root (/) of a Web application, but simply use the managed path/sites for convenience in your development environment.

  1. Open a new instance of Notepad. Create a PowerShell script in this simple editor for this portion of the lab. Also, find the Feature Id GUID that you saved earlier in a Notepad document, and copy it to your Clipboard.
  2. Add the following lines at the top of the script to set some variables and values to reuse throughout the script:
$scUrl = “Url of the site”
$scOwner = “domain\userID”
$template = “{pasteFeatureIdGUID}#DemoTemplate”

 Paste the Template Id GUID from your Clipboard over pasteFeatureIdGUID (retain the { } brackets). Also replace the domain\userID with the account that you use (that is a farm admin).
  1. Add the following line to create a new site collection and provision its rootweb:
New-SPSite -Url $scUrl -OwnerAlias $scOwner-template $template -name "Home/News"
  1. Next, provision the Executives site with the next line:
New-SPWeb ($scUrl + "/Executives") -template $template -name "Executives" | ft -p url

The| ft -p url simply formats the output that you see when you run the script.
  1. Continuing adding lines for all the sites listed in the desired site taxonomy. You need to copy and paste only the preceding line and change the two places where Executives displays, making sure that in the first instance you add the entire hierarchical path to the siteAfter you complete your script, save it into the c:\Demo folder, and call it ProvisionSites.ps1
  2. Open the SharePoint 2010 Management Shell.
  3. Type in the following line to execute your provisioning script: c:\lab2\ProvisionSites.ps1
  4. When your script completes without errors, open a web browser to the url we given earlier
  5. In addition to verifying that all the sites in the hierarchy have been created, you should also test to see that all the customizations you made to your template (versioning settings in the Shared Documents library) and initial content (the files you uploaded) are present.
Share: 


Didn't find what you were looking for? Find more on How to Deploy a Site Taxonomy in SharePoint 2010 Or get search suggestion and latest updates.

Destin Joy
Destin Joy author of How to Deploy a Site Taxonomy in SharePoint 2010 is from Pathanamthitta, India. Destin Joy says

 Hello Everyone,

I am Destin Joy from India I have MCPD in SharePoint 2010, MCTS SharePoint 2010 application development and MCTS in SharePoint 2007. I am mostly working in  core part of SharePoint (2010-2007) and passionate about new Microsoft technologies. Born and brought up in Kerala You can reach me  @ Destin.Joy@hotmail.com

 

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!