SilverStripe Module: Canonical URLs SilverStripe Module: Canonical URLs

SilverStripe Module: Canonical URLs

SilverStripe Module: Canonical URLs

This a SilverStripe module that enables developers to conveniently integrate the required metadata for defining the canonical URL of any SiteTree page, or DataObject Controller in a SilverStripe project. This is required by search engines for ensuring that duplicates of the same page do not appear in search engine results. For instance, two domain names could be pointing to the same static page or endpoint of a given server. This kind of behaviour is considered to be "spammy" by search engine crawlers, and Google or Bing will relegate search results caught adopting this approach.

Quoted from Google's Developer Pages:

"If you have a single page that's accessible by multiple URLs, or different pages with similar content (for example, a page with both a mobile and a desktop version), Google sees these as duplicate versions of the same page. Google will choose one URL as the canonical version and crawl that, and all other URLs will be considered duplicate URLs and crawled less often."


Installing this module is as simple as running the following command from a terminal.

composer require loveduckie/silverstripe-canonical

After the installation has completed successfully, then simply ensure that you have navigated to /dev/build?flush=all of your SilverStripe project. This will ensure that all required database fields are created, and are available from the site configuration panel.


Once you have installed this module, you will need to define the canonical URL of your website from the SilverStripe configuration panel that's available in the admin dashboard (available at /admin by default). It should look something like this in your configuration panel.

The canonical URL used for rendering the meta tag with.

SilverStripe Module: Canonical

Ensure that the canonical URL used does not include www., otherwise you will likely encounter erroneous behaviour when Google crawls your site.