Silverstripe Canonical URL

Canonical URLs can be useful for SEO. Silverstripe does not include these by default so I’m going to show you 2 ways to add a Silverstripe canonical URL to your site.

Method 1

The most logical approach in my opinion, simply pull the url into our SS template. Do this by copying the following function into your Page_Controller class.

function CanonicalURL() {
   return Director::protocolAndHost() . $this->Link();

Then copy the following into the head of your SS template.

<link rel="canonical" href="$CanonicalURL">

read more