The Links table in Sitecore is a critical component that maintains a record of all the relationships between items across different databases, such as Core, Master, and Web, as well as across different language versions. It ensures that links between items are accurately tracked and managed.
Purpose of the Links Table
The Links table serves to:
- Track Relationships:
- Maintains links between items, such as internal links, field references, and layout dependencies.
- Support Features:
- Enables Sitecore features like Link Database, Publishing Restrictions, and Broken Link Detection.
- Provides essential data for media usage and item dependencies.
- Event-Driven Updates:
- The table is automatically updated when specific item events occur:
item:copied
item:deleted
item:saved
item:versionRemoved
- The table is automatically updated when specific item events occur:
Link Database Implementations
Sitecore offers two primary implementations for managing the Links table:
- Default Implementation:
Sitecore.Links.DefaultLinkDatabase
(from Sitecore Kernel) is the default provider.- Each database (Core, Master, Web) maintains its own Links table.
- Custom Configuration (Explicit Mode):
- You can configure which databases store link data by enabling the
Sitecore.LinkDatabase.Explicit.config
file. - This allows more granular control over where links are stored and retrieved.
Example configuration:
xml<linkProvider key="master"
type="Sitecore.Data.Master.MasterLinkDataProvider, Sitecore.Kernel">
<param ref="dataApis/dataApi[@name='master']" param1="masterConnectionString" />
</linkProvider>
You can set up similar configurations for
Core
andWeb
databases. - You can configure which databases store link data by enabling the
Rebuilding the Links Table
Sometimes, you may need to rebuild the Links table, especially during:
- Upgrades to a new Sitecore version.
- Resolving broken links or inconsistencies.
Steps to Rebuild the Links Table:
- Open Control Panel:
- From the Sitecore Launchpad, navigate to Control Panel.
- Select Rebuild Link Databases:
- In the Database section, click Rebuild Link Databases.
- Choose Databases:
- Select the databases you want to rebuild, typically Master and Core.
- Start Rebuild:
- Click Rebuild to regenerate the Links table.
Benefits of Rebuilding
- Fixes Link Inconsistencies:
- Ensures that all item relationships and dependencies are accurately reflected.
- Improves Performance:
- A clean and updated Links table can enhance the efficiency of content searches and publishing.
- Supports Upgrades and Maintenance:
- Ensures smooth transitions during version upgrades or major system changes.
Best Practices
- Monitor Links Table Growth:
- Regularly check the Links table size, as excessive growth can impact performance.
- Use Rebuild During Off-Peak Hours:
- Rebuilding can be resource-intensive, so schedule it during maintenance windows.
- Backup Before Rebuild:
- Always take a backup of your databases before performing a rebuild to prevent data loss.
- Enable Explicit Mode When Necessary:
- Use the
Sitecore.LinkDatabase.Explicit.config
to control link storage if you have specific requirements for managing large-scale or multi-environment setups.
- Use the
Conclusion
The Links table plays a crucial role in maintaining the integrity of item relationships in Sitecore. Understanding how it works, how to configure it, and when to rebuild it ensures your Sitecore environment operates efficiently and reliably.