In this blog post, we will discuss a common issue which we faced in Sitecore XM Cloud where items marked with the “Never publish” setting appear in listings when their parent folder is used as a data source item. We will walk through the steps to create a custom content resolver to address this problem effectively.
When an item is marked as “Never publish” in Sitecore XM Cloud, it should not be visible on the website. However, there are cases where these items still appear in listings, even though they return a 404 error when accessed directly.
To fix this, we raised a Sitecore ticket and the recommendation was creating a custom contents resolver. Here’s a detailed breakdown of the steps:
1> Rendering for this data source item used “Sitecore.LayoutService.ItemRendering.ContentsResolvers.RenderingContentsResolver” as a content resolver (there is no a check to filter out items that have enabled “Never publish” checkbox in this resolver) which exists in the dll “Sitecore.LayoutService”. We then extracted the code of “ProcessItems” from the type “RenderingContentsResolver” in the namespace “Sitecore.LayoutService.ItemRendering.ContentsResolvers”. This content resolver does not has check to filter out items that have enabled “Never publish” checkbox.

2> Create a Custom Contents Resolver that inherits from “Sitecore.LayoutService.ItemRendering.ContentsResolvers.RenderingContentsResolver”.
3> Override the “ProcessItems” method to include a check for the “Never publish” setting.

4> Set the Custom Resolver Type
a> Assign custom resolver type to the rendering.
b> Republish the page to ensure the custom resolver is applied.
After implementing these steps, the issue was resolved, and the item marked as “Never publish” was no longer visible in the listings.
We can create a custom content resolver in Sitecore XM Cloud that properly filters out items marked with the “Never publish” setting. This ensures that our listings only display items intended for publishing, improving the overall user experience.
Hope this will helpful!!