Assign the new SEO rel="canonical" link tag in HEAD of page
Posted: Sat Feb 14, 2009 2:31 am
Search engines have agreed to adopt the rel="canonical" link to help prevent duplicate content in search engines. This is especially important for CMSMS users because a page can be viewed using a variety of URLs. For example,
http://domain.com/parent-alias/child-alias is accessible using:
http://domain.com/foo/child-alias
http://domain.com/child-alias
so, search engines need to know which is the 'real' page. The tag will tell Google, Yahoo, and MSN Live that http://domain.com/parent-alias/child-alias is the real page regardless of how it is accessed.
The link should be placed in the . Instead of setting each one individually using the metadata content of the page editor options tab, use this UDT. (I grabbed code from a calguy1000 UDT at http://forum.cmsmadesimple.org/index.ph ... 440.0.html)
Create a User Defined Tag called 'canonical' using: EDITED 2-14-09
It will produce a proper canonical link for you. For more information about this soon to be very popular tag, read http://www.seomoz.org/blog/canonical-ur ... e-sitemaps and http://googlewebmastercentral.blogspot. ... nical.html
At some point I'll try to add a plugin to the forge.
Question:
Does any one know if there are any implications when using SSL ? Should the tag test for https somehow?
http://domain.com/parent-alias/child-alias is accessible using:
http://domain.com/foo/child-alias
http://domain.com/child-alias
so, search engines need to know which is the 'real' page. The tag will tell Google, Yahoo, and MSN Live that http://domain.com/parent-alias/child-alias is the real page regardless of how it is accessed.
The link should be placed in the . Instead of setting each one individually using the metadata content of the page editor options tab, use this UDT. (I grabbed code from a calguy1000 UDT at http://forum.cmsmadesimple.org/index.ph ... 440.0.html)
Create a User Defined Tag called 'canonical' using: EDITED 2-14-09
Code: Select all
global $gCms;
if ($gCms->variables['page_name'] !='') {
$manager =& $gCms->GetHierarchyManager();
$node =& $manager->sureGetNodeByAlias($gCms->variables['page_id']);
$content =& $node->GetContent();
if (isset($content) && is_object($content))
{
if ($content->GetURL() != '')
{
echo '<link rel="canonical" href="'.$content->GetURL().'" />';
}
}
}
At some point I'll try to add a plugin to the forge.
Question:
Does any one know if there are any implications when using SSL ? Should the tag test for https somehow?
Code: Select all
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;