Sitecore - publish all items linking to a particular item

Posted 14 Dec 2021 by Marek Musielak

sitecore publish all items linking to a particular item

Sometimes you need to publish all items linking to a particular Sitecore item. While Sitecore has an option to publish item with related items, it only publishes items which are referenced from the item. It does not publish items which link to selected item. Here is easy Sitecore Powershell Extensions script which allows to publish all the items which refer to your selected item:

$myItemId = "{5D95F2CF-6D5C-4AAC-A4C6-21A0A847BCB5}"
$referrers = Get-ItemReferrer -Path $myItemId

foreach ($referrer in $referrers) {
    Publish-Item -Item $referrer

This script uses `Get-ItemReferrer` function which utilizes Sitecore Link Database. If you want to be sure that all the items are processed correctly, make sure that your Sitecore Link Database for master database is up to date before running the script.

Sample use case? Image you want to delete an item called "Privacy Policy 2021". While deleting, Sitecore shows Breaking Links dialog and asks you to choose what to do with existing links to your item. You choose Link to another item and select "New Privacy Policy 2022" page. Everything seems to be fine? Not really. If you publish deletion of old "Privacy Policy 2021" item, all the pages which link to that item won't be published together automatically as they are not referenced from neither old or new item. So in web database they will still link to the old item. That's an example scenario when you want to use my script. After you use Link to another item option, run my script using Sitecore ID of the new item - that will publish all the items which now link to the new item, so no more broken links in web database anymore.

Comments? Find me on or Sitecore Chat