How To Import and Export Sitecore Content

Moving data between your dev environment and your test/production is a common requirement. To make your life as easy as possible, we want to avoid manually having to re-type in data over and over again for each environment. Luckily for us, Sitecore has a few options available to help us out. In today's tutorial, I'm going to cover how to import and export content using Packages as it's the free inbuilt tool available to us which also works with Sitecore Rocks.

What Are My Options For Import Content Into Sitecore

When it comes to importing content into Sitecore, we have these options:
  • TDS/Team Development for Sitecore: TDS give you the ability to store all of your Sitecore items within source control. This includes templates, layouts, and content. TDS allows you to import/export data, so to move data between environments, all you need to do is merge your TDS items from your dev branch into your test branch and everything will import like magic. TDS basically serializes your Sitecore items so they live in physical files rather than bits of data within your database. This can then be combined with tools like glass mapper to convert these files into C# classes to allow for unit testing and a whole number of cool things. The only downside of TDS is that it costs £800 a license, with each developer on the project needing one. If you can afford this (and in the big picture the costs are very trivial) then this is the approach I would recommend.
  • The Sitecore API: Sitecore has a very powerful C# API. If you want to move custom items that might live outside of Sitecore, like Wordpress for example, then this is the route you will need to investigate. Writing custom code takes time but if you have thousands of blog posts you want to integrate, then it can save you a lot of time in the long run.If, however, you want to import Sitecore items, then the time to write code just isn't worth it when you have out the box functionality.
  • Packages: For a lot of projects, package deployment is the most viable option. In Sitecore, you create your package adding whatever files you want. In the next environment you simply import it and job done!

How To Create A Package

So, for this tutorial, I'm going to assume that you use Sitecore rocks as this will make your life easier and quicker. You can also create packages directly in Sitecore. If you open the Sitecore dashboard, 'Development Tools' -> 'Package Designer' you should be able to figure the rest out from there. I find Sitecore Rocks a lot more usable, so let's carry on. Open your Sitecore Rocks Explorer and navigate to the item you want to export and press Shift and right click. This should highlight it. You can now repeat this process until you've selected all the files you want to export. One good thing to note, if you want to include 'child' items, you need to right click on an item and selected, the include children option. sitecore_exporting_content When you have everything you need exporting highlighted, right-click on an item and in the Sitecore Rocks context menu, select 'Tools' -> 'Create package'. sitecore_exporting_content_1 The next screen is to add any package details, as we are creating an internal package I don't usually bother creating too much package information. Usually, I'll just set the package name as 'Content-Date'. and leave the rest. You also might want to check the 'Items' tab to double check you have added everything you want. When you are happy, hit 'Build' and the package manager will create a zip file containing the packages data in it.

Importing a Package

Importing a package is also very easy, go to your Sitecore dashboard, select the 'Start Menu' -> 'Development Tools' -> 'Installation Wizard' sitecore_package_importing_installation_wizard You should now see be prompted to upload a zip file sitecore_package_importing_1 From here select the 'upload' button and locate the package on your PC. Click 'Next' sitecore_package_importing_2 The next screen is just a summary of the packages contents, as we've created it ourselves, we can skip this, click 'Install' and sit back. Your content will not be imported sitecore_package_importing_3 As we're only importing content, you can de-select both the 'Restart' options. Now, if you look in your Sitecore instance you should see the imported content! Job done!

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

Back to top