I have come across a few large Silverstripe websites with broken internal site link tags in the $Content: [sitetree_link,id=]
For the link tag to work properly it needs an ID: [sitetree_link,id=123]
Without a numerical ID the link tag is simply rendered into the $Content HTML and causes a broken link: http://www.example.com/[sitetree_link,id=]
These websites often have hundreds of pages so manually removing these links would be incredibly time consuming.
One approach I thought of was writing some code OnPublish which removes the empty internal site link tags. But I wanted to check that a (better) solution doesn't already exist.
What is the best way to automatically remove empty [sitetree_link,id=] tags in Silverstripe?
I would advise against automatically removing the links.
Removing the links will make them incorrectly point to the home page. It will also make it much more difficult to find and fix these broken links.
The SilverStripe admin has a broken links report that can be found at the following url:
[site-address]/admin/reports/BrokenLinksReport/
We can use this report to find and fix any broken links in our site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With