The "Never Publish" Field
Sitecore has a standard field for items called Never Publish
that allows content authors to prevent publishing. It's powerful functionality, but it has more than a few caveats.
The Subtle Details of Never Publish
- When you set an item to never be published, the change applies immediately, even in preview mode. If you try to preview the item, you won't be able to. This might be Sitecore's way of making it very apparent to users that the item will not exist. If you were able to preview the item, it could give you a false sense of the final state in your web database.
- The field is a shared value, so it will apply to all languages. It will also apply to all versions of the item.
- The never publish behaviour will also cascade down to child items, though the child items won't have the field checked as a result of checking a parent item. The child items also won't indicate that they will never be published.
- Any links to unpublished items will not resolve (be sure to check which items reference the item).
How to Build for Never Publish (Do Your NULL Checks)
Never Publish
effectively removes the item and subitems as far as your code and website is concerned. Some content authors use this functionality more than you would think in order to hide content from being publicly visible.
Any time you're dealing with objects in your code behind, Sitecore is particularly vulnerable to NULL exceptions when you're getting an item from the database. Do your null checks. As you build new functionality that depends on certain Sitecore items, always build with Never Publish
in mind. Never Publish
is also a great way to test your code for how robust it is in NULL situations rather than deleting the item.
Good luck out there,
Marcel