Level: 100
 

Publishing and versioning

Newspaper

In this article, I will explain the key concepts related to publishing content in Sitecore.

 

We will take a look at the different ways to publish content, how to check your new content before publishing and see how its possible to save old versions of your content.

Written by: Jimmi Lyhne Andersen
Wed, Jul 29 2009

What is publishing?

Publishing is an essential part of working in Sitecore. Every time you edit or create new content you have to publish it to see it on your website.

 

What technically happens when an item is published, is that it is copied from the master database to the web database. It is the content of the web database that is shown on the website.



Why publish?

There are several reasons why you need to publish your content.

 

For the individual editor it allows you to work on a page and save your progress without your work appearing on the website before you have finished it.

 

Or maybe the organization has decided that all content should be approved before appearing on the website. This is typically done by putting a workflow on all items.



Ways to publish content

Sitecore provides several different ways to publish content. You can decide how much of the content tree you want to publish, and you can choose between three different ways to publish the selected items.



The three ways to publish items are:

  1. Republish: This method will publish every item, even items that have not changed. If you are publishing on a large website this method of publishing can take a long time. It is intended to be used when you are publishing to a new web database, if you are restoring a backup of the master database or similar situations.

  2. Smart publish: This method compares each item in the master database with the item in the web database. In Sitecore each item has a internal revision identifier and it is this identifier that is compared. If they are different, that is, the item has been changed since it was last published, the item will be published. Even though this method is still comparing each item, it is much faster than doing a republish.

  3. Incremental publish. Every time an item is changed, it is added to the publishing queue. This applies both to changes made through the Sitecore user interface and changes made programmatically. Doing an incremental publish will only publish the items in the publishing queue. Therefore only items that has been changed will be published and Sitecore does not have to do any comparisons to figure out which items has been changed. This way of publishing is therefore by far the fastest. Republish and smart publish do not use the publishing queue.



As mentioned it is possible to decide how much of the content tree that should be published.

 

If you want to publish the entire site and you are in desktop mode you can click the Sitecore button and choose Publish Site. If you are in content editor mode you should choose the Publish tab, click on Publish menu and choose Publish Site. Both of these will open the Publish Wizard where you can choose between republish, smart publish or incremental publish.

 

Screenshot of content editors publish tab



If you only want to publish a subtree, you should choose the root item for that subtree and again choose the publish tab, click the publish menu and choose publish item. That will open the publishing wizard. Check the Publish Subitems checkbox and choose between either smart publish or republish. Remember that incremental publish is publishing the items in the publishing queue, thats why you cannot choose it to publish a sub tree.

 

If you just want to publish a single item, you can click on the publish icon in the publish tab.



Versioning

Versioning is very useful for several things. First of all it allows you to keep old versions of your content, but it can also allow you to create content that is to be published on a later date.

 

To make a new version of an item, go to the Versions tab in the content editor and click on the Add button.


 Screenshot showing how to add a new version of an item


This will copy the content of the item to a new version, which you can start working on without loosing the content stored in version 1. You can switch between different versions of the item by clicking on the version number, see the above screenshot.

Publish restrictions

So what if you want to remove a page from the website but you do not want to delete the item.

 

Or maybe you only want the page to be on the website for a certain time period. Or maybe you want different versions of the item to be shown on the website on different time periods.

 

This is all possible with publish restrictions.

 

Let us run through these scenarios one at a time.

 

If you want to remove a page from the website without deleting its item in Sitecore, you go to the Publish tab in the content editor and click Change.

 

 Publish restrictions

This will open the publishing settings. Now click on the Item tab and uncheck the Publishable checkbox. After doing this you will have to publish the item, and it will disappear from the website.


If you create a page that should only be shown on the website for one month, you again open the publishing settings where it is possible to set a publishable to date. After this date the item will no longer be shown on the website. Be careful though, the item is only removed from the website after it has been published. A lot of editors misunderstand this part. After the publishable To date has passed the item is removed from the website after it has been published.

 

Now, imaging we create an item that has four versions, each version should be shown for one quarter. So one version is shown in the spring, one in the summer, one in autumn and one in the winter.

 

Again we open the publishing settings and go to the Versions tab. And enter the dates like in the following screen shot.

 

 Publishing viewer showing publishing restrictions for different versions

Again it is important to remember that the item should be published after entering a new quarter or else the version will not change on the website.

 

You should be careful not to have a published item without any published versions as this can result in strange errors in you website depending on how robust the website was implemented.

The Publishing Viewer

To get an overview of which version is published in which time period, you can use the publishing viewer. It is located under the Publish tab in the content editor.


 Publishing viewer

Here the green bars indicate which version is published on a certain time, and the blue bar indicates when the item is published.



Preview

A preview of how the web page will look at a certain time can be seen using the preview functionality. In the Publish tab of the content editor click the Preview button. A new window opens displaying the web page.

 

 Screenshot of preview mode

 

If you click the Ribbon button (I think Sitecore forgot to give this button a name :)) a number of preview options will appear. Click the date to select for which date the page should be previewed.

Preview only displays items and versions that are publishable, therefore if you want to preview a page that has publishing restrictions, you have to set the preview date to a date where the page is publishable.



A Little Warning

If you are running a large web site with a lot of editors, publishing can really hurt performance. This is due to Sitecore's caches being cleared after a publish.

You can read more about caching in Sitecore here.

 

Please rate this article


6 rates / 4,5 avg.

  • Picture of Jimmi Lyhne Andersen

    About the author:

    Jimmi Lyhne Andersen

    Jimmi Lyhne Andersen is the co-founder of LearnSitecore, and is a partner at Inmento Solutions.
    Jimmi has been lead developer and architect on several large public websites with 200+ editors, and is therefore focused on usability and accessibility.
    Jimmi is a certified Sitecore developer and a Microsoft Certified Professional Developer (MCPD).
    He has a bachelors degree in Computer Science and in Mathematics from the University of Copenhagen.

     

20 responses to "Publishing and versioning"

Great Article.

I am publishing an item wiith 3 languages. After publish it shows me

Job started: Publish to 'web'
Items created: 0
Items deleted: 0
Items updated: 2
Items skipped: 0
Job ended: Publish to 'web' (units processed: 2)
Job started: Publish to 'web'
Items created: 0
Items deleted: 0
Items updated: 2
Items skipped: 0
Job ended: Publish to 'web' (units processed: 2)
Job started: Publish to 'web'
Items created: 0
Items deleted: 0
Items updated: 2
Items skipped: 0
Job ended: Publish to 'web' (units processed: 2)


Question : why does it process 2 updates for each item
Posted: Wednesday, February 09, 2011 3:51 AM
EMR
This is my first visit here. I found some really interesting stuff in your blog especially this discussion. Keep up the good work.
Posted: Thursday, March 17, 2011 8:18 AM
Quite interesting updates
Posted: Friday, October 21, 2011 11:52 AM
You can share some of your article, I'm like you write something, really very good! I will continue to focus on. Never done in the article comments, this is my first network comments, appreciate you sharing. Very good article
Posted: Saturday, October 22, 2011 4:03 PM
Great, I've been looking for this Information for a couple of an hour, Thanks for the good insight here
Posted: Sunday, October 23, 2011 5:58 PM
Great post! We’re actually getting ready to do more ezine marketing and sounding this post is very useful my friend. Also great blog here challenging valuable information you’ve got. Sustain the excellent work you do here.
Posted: Monday, October 24, 2011 9:20 AM
Your post provided me with some nice new thoughts - an extremely solid read. I simply recorded a fast podcast about a similar subject. Maybe you have considered podcasting? I strongly recommend it!
Posted: Monday, October 24, 2011 9:21 AM
It is awesome work.No one can ignore the hard work required to maintain such high quality throughout.Thanks for the quality stuff.
Posted: Tuesday, October 25, 2011 7:11 AM
Thank you for another essential article. Where else could anyone get that kind of information in such a complete way of writing? I have a presentation incoming week, and I am on the lookout for such information.
Posted: Tuesday, October 25, 2011 12:43 PM
This site appears to get a great deal of visitors. How do you promote it? It offers a nice unique twist on things. I guess having something useful or substantial to talk about is the most important thing.
Posted: Tuesday, October 25, 2011 6:48 PM
I have invested my time in reading a wonderful post like this
Posted: Friday, October 28, 2011 6:31 AM
I dont know what to say. This blog is fantastic. Thats not really a really huge statement, but its all I could come up with after reading this. You know so much about this subject. So much so that you made me want to learn more about it. Your blog is my stepping stone, my friend. Thanks for the heads up on this subject.
Posted: Friday, October 28, 2011 9:21 PM
Great blog always offer the best information and authentic, without creating an exaggeration. This blog has given me the opportunity to learn many things about the products and services.
Posted: Friday, November 25, 2011 11:13 AM
Thanks for sharing great information. Your site is very cool. I am impressed by the details you have on this website. It shows how well you perceive this issue. Marking this website, return to the additional items. You, my friend, Rock! I found just the information you previously searched everywhere and could not come through. What a great website.
Posted: Monday, December 12, 2011 8:28 AM
Great accurate, I was searching on this for a while. Bookmark and recommended!
Posted: Saturday, December 17, 2011 7:34 AM
Ben
Looks like someone needs a better captcha.
Posted: Thursday, December 22, 2011 8:45 PM
I like the valuable info you have on your pieces of content. Factors. favorites of your site and take a look at the times right here consistently. Now I'm extremely precise factors. Find below several different things! All the best place for your future!
Posted: Tuesday, January 10, 2012 1:30 PM
Great job! I always like to leave comments when I see something unusual or impressive. I think we must appreciate those who do something special. Keep it up, thank you
Posted: Friday, January 13, 2012 7:51 AM
I really appreciate your professional approach. These are pieces of very useful information that will be of great use for me in future. Thanks for it.
Posted: Monday, January 16, 2012 1:57 PM
Thank you for sharing this interesting blog. In fact, Google was the search for simple information on any subject. Well, keep and publish blogs more interesting.
Posted: Monday, January 23, 2012 1:34 PM

Leave a reply

Captcha
 
Notify me of follow-up comments via email.
 
 
#nbsp;