protected function generateCanonicalUrl()
    {
        $extCompat7 = ExtensionManagementUtility::isLoaded('compatibility7');
        //User has specified a canonical URL in the page properties
        if (!empty($this->pageRecord['tx_metaseo_canonicalurl'])) {
            return $this->generateLink($this->pageRecord['tx_metaseo_canonicalurl']);
        }

        //Fallback to global settings to generate Url
        if (!empty($this->tsSetupSeo['canonicalUrl'])) {
            list($clUrl, $clLinkConf, $clDisableMpMode) = $this->detectCanonicalPage(
                $this->tsSetupSeo['canonicalUrl.']
            );
            if (!empty($clUrl) && isset($clLinkConf) && isset($clDisableMpMode)) {
                $url = $this->generateLink($clUrl, $clLinkConf, $clDisableMpMode);
                return $this->setFallbackProtocol(
                    $extCompat7 ? $this->pageRecord['url_scheme'] : null, //page properties protocol selection
                    $this->tsSetupSeo['canonicalUrl.']['fallbackProtocol'],
                    $url
                );
            }
        }

        return null;
    }