if (isset($wgArticle)) {
$out->addHeadItem( 'canonical',
'<link rel="canonical" href="'.$wgArticle->getTitle()->getFullURL().'" />'."\n");
} else {
$out->addHeadItem( 'canonical',
'<link rel="canonical" href="'.$CanonBaseURL.$pg_title.'" />'."\n");
}
Topic on Extension talk:CanonURL
Appearance
Don't forget to run the attribute value through htmlspecialchars()
, and use Title::getCanonicalURL
instead of Title::getFullURL
so that sites that support both HTTP and HTTPS output the canonical url here instead of the one on the current request.