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


10 rates / 4,3 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.

     

14 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
Ben
Looks like someone needs a better captcha.
Posted: Thursday, December 22, 2011 8:45 PM
Can you advice on publishing related items and media links.
Posted: Wednesday, February 08, 2012 6:59 PM
Please look up the following link, the question which i have regarding publishing restrictions.

http://stackoverflow.com/q/9428346/1187148
Posted: Friday, February 24, 2012 12:48 PM
It is the content of the web database that is shown on the website.
Posted: Saturday, January 12, 2013 11:29 AM
testthank77
Posted: Saturday, October 05, 2013 10:30 AM
can u help me out for how may i track if somebody change the HTML and CSS. Is there any way to track in sitecore CMS
Posted: Tuesday, December 10, 2013 11:23 AM
Thank you for posting this.You most absolutely have built this blog website into something special.
Posted: Saturday, February 28, 2015 7:49 PM
I read few posts on this web site and I conceive that your blog is very..
Posted: Tuesday, May 05, 2015 10:46 AM
Bob
How do I retrieve, then unpublish, something that I accidentally deleted first, before unpublishing, as is proper? The item still appears on our site, with a 404 error for the link to it. Or, should I just publish the root directory, which no longer contains the deleted item, and this will solve the problem?
Posted: Thursday, May 21, 2015 8:19 PM
Is there any auto publish option in sitecore. Only we can set the time in the sitecore tab-> Change. While giving this details the item will be published by the time given or manually the user needs to do publish.
Posted: Wednesday, July 29, 2015 9:38 PM
Is there any auto publish option in sitecore. Only we can set the time in the sitecore tab-> Change. While giving this details the item will be published by the time given or manually the user needs to do publish.
Posted: Wednesday, July 29, 2015 9:38 PM
Is there any auto publish option in sitecore. Only we can set the time in the sitecore tab-> Change. While giving this details the item will be published by the time given or manually the user needs to do publish.
Posted: Wednesday, July 29, 2015 9:39 PM
This is very good comment you shared.Thank you so much that for you shared those things with us.I am wishing you to carry on with your achievement.All the best..Thanks for sharing.
Posted: Tuesday, December 01, 2015 7:58 AM

Leave a reply


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