How to Setup a Sitecore Preview Site to Review Content Before Publishing

Sitecore’s fundamental architecture is full of features that allow editors to create content and review it before the content is promoted to a public-facing website. This can be accomplished using built-in preview tools or by publishing content to non-public preview websites. Though these options exist, they may be time-consuming to setup or costly to setup (i.e. for licensing reasons). One approach that I will explain it to setup a “poor man’s staging solution” that uses the existing Sitecore instance to show master database content before it is published. Lets get into the details.

Publishing Primer

First, let’s re-cap basic publishing. Content editors make changes to content items in the master database. They can use the preview ribbon to open a preview of the content in the actual site. When the content is to be made live, they publish the content to the web database (by default, named as the Internet publishing target). This is all great, but what if you want someone to review content before its published and they cannot access Sitecore (meaning they can’t use Preview mode)? Well, that’s where the “poor man’s staging solution” comes in.

Configure a Preview Site

The concept is quite simple to setup a preview URL:

  1. Determine a (sub)domain for preview (e.g. preview.mysite.com) and setup DNS as needed
  2. Add the preview host to the existing IIS Sitecore instance
  3. Add a new <site> node to the Sitecore instance’s web.config
  4. Set the new site to listen to the master database

For demo purposes, I will use the host preview.mysite.com as our example. So the primary thing we need to do is to create a new <site> node above the standard “website” node. Here’s an example:

[sourcecode]

<site name="website_preview" filterItems="false" enableWorkflow="true" hostName="preview.mysite.com" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" database="master" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />

<site name="website" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="10MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />

[/sourcecode]

There are just a few important attributes on the new preview node that need to be made for this to work:

  • Load content from the master database: database="master"
  • Set a hostName to bind to: hostName="preview.mysite.com"
  • Don’t filter items which preserves some basic item restrictions: filterItems="false"
  • Enable workflow: enableWorkflow="true"

And the best thing is, all of these steps I’ve outlined come directly from Sitecore, so I’m not making anything up: How can i set “Live” Mode on my site?

Caveats

This solution does have some caveats that need to be considered:

  • The HTML output caches need to be manually cleared if you’re modifying cached content and need to preview it. This is because these caches are normally cleared on publish. One possible way to get around this issue is to set the size of the HTML cache for the preview site to 0MB, but I have not tried it.
  • If you use Lucene indexes, they will not be updated. This is because you’re indexes are probably indexing web content and get added during publish operations.

Feel free to comment about any other approaches you’ve taken to do something like this.

 

Mark Ursino

Mark is Sr. Director at Rightpoint and a Sitecore MVP.

 

13 thoughts on “How to Setup a Sitecore Preview Site to Review Content Before Publishing

  1. I use the same technique pretty regularly, especially since it staves off content editors from pushing content through workflow and only publishing to a CMS preview target, which is a recipe for disaster. Regarding HTML cache, I think you can also just set cacheHtml=”false” in the entry.

  2. Hi. I’ve just read your post, and maybe you know. I would like to experience how to find by search on Google, Yahoo … those blogs that have this option (plug-in) active as Preview Comments. How can I do this?

  3. Great post!!

    How does user roles and permissions work witht his approach?

    Does links to other content properly work with this?

    Thanks in advance and keep up the good work.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.