Dude Where's my Rendering Used
SXA is an amazing addition to Sitecore, but page designs and partial designs can make it hard to see what pages use a particular rendering.
In vanilla Sitecore, select a rendering in the Content Editor, click Navigate > Links to show a list of items using that rendering.
In SXA this is more tricky because we have the following links between renderings and pages:
Page referencing a page design:
- Rendering
- Partial Design
- Page Design
- Page
Page linked to page design via Page Designs setting:
- Rendering
- Partial Design
- Page Design
- Page Designs
- Page Templates
- Pages
To get around this, I wrote a Sitecore PowerShell Extensions (SPE) script to help. You can find it on github here: https://gist.github.com/dresser/960d9943c3a8c9b17f0a36ca0839e6db
How to use the script
- Go to Sitecore Desktop
- Click PowerShell ISE
- Paste the script into the editor
Now you need to make a few edits to the script to make it work for your solution:
- Change $presentationPath to point to the "Presentation" folder of your site
- Change $metadataPartialDesignTemplateId to the ID for your solution - SXA solutions will often have numerous templates inherited from SXA foundation templates, your solution is likely to be using a derived template hence this ID needs to be updated. This template should inherit /sitecore/templates/Foundation/Experience Accelerator/Presentation/Metadata Partial Design
- Change $partialDesignTemplateId to the ID for your solution - the SXA Foundation template is /sitecore/templates/Foundation/Experience Accelerator/Presentation/Partial Design
- Change $pageDesignTemplateId to the ID for your solution - the SXA Foundation template is /sitecore/templates/Foundation/Experience Accelerator/Presentation/Page Design
- $homePagePath to the Home item path for your site
When you run the script you will be prompted "Enter the ID of a rendering:" here you simply paste the ID of the rendering you are looking for and then click OK. If the script found usages of the rendering, it will be displayed in an output table.
Hope this helps someone. Let me know in the comments section below if you have any problems or suggestions!