Content items locations API

The article describes how Sitefinity CMS resolves content locations. It explains what ContentLocationService is, how to use it, and what problems can you solve with it. It clarifies what are a locations and their priority, and how you can set them.

Sitefinity CMS comes with a service called IContentLocationService. It gives you the ability to know the locations of an item in the system – these are the actual URLs of a content item in the context of the pages where it is displayed. Each Sitefinity CMS content widget uses the service to register the location of the content item on the page. For example, if you have a News widget on a page from your site, after you publish the page, Sitefinity CMS knows that on this page you have a widget capable of displaying content of type News. It also knows the exact content items that the News widget is configured to display. IContentLocationService API is also used internally to bring several key benefits to the product:

  • Generating the Preview location of a content.
    When you edit a content item and click on the Preview button, Sitefinity CMS displays this item in the context of the page where it is used, loading the page content and styles, thus allowing you to see how your content is going to look like on the page, once you publish it.
  • Listing the pages where an item is published.
    All content modules now have the option to show a list of pages where the type of content is published. You can see the list and modify the priority of the pages.
  • Provide a canonical URL tag for content items.
    The first location in the list of pages where an item is published is the canonical (default) location. The Sitefinity CMS widgets includes a rel="canonical" parameter when generating the link to the item, thus ensuring proper SEO.

    IMPORTANT: The default location of an item must be a page that is accessible by all users, that is, they have permissions to view it.

  • Generating the search results.
    You do not have to specify a default page where a content type is published when you create your search index. Sitefinity CMS uses the IContentLocationService API to resolve the default page where an item is shown and uses this information to build the link to this item in the search results.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?