Assign the new SEO rel="canonical" link tag in HEAD of page

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: Assign the new SEO rel="canonical" link tag in HEAD of page

Post by JohnnyB »

I agree with some of these points.
Im used to create one page like 'news' and set all the news using the detail page. The canonical URL will be the same for all news. This will confuse or limit the search engine approach on site. And for any other module it wont work too, since most of then uses the current page alias to display detail views.
I do the same thing too ;)
As calguy and other developers mentioned before on many discussions, we agreed that the best thing you can do is prevent the search engines to index your site before the definition of the url scheme and/or other tweaks.
True, but let's not forget the client or editor that manages a site using CMSMS. If they add a link in the text that does not follow the hierarchy, that link will be indexed by the search engines.
Google wont penalize you for duplicated content, but probably will make your pages less relevant or simply exclude some of then  from the standard listing.
Here is what Google writes:

From: http://googlewebmastercentral.blogspot. ... nical.html
Carpe diem on any duplicate content worries: we now support a format that allows you to publicly specify your preferred version of a URL. If your site has identical or vastly similar content that's accessible through multiple URLs, this format provides you with more control over the URL returned in search results. It also helps to make sure that properties such as link popularity are consolidated to your preferred version.

With rel="canonical", properties of the two URLs are consolidated in our index and search results display wikia.com's intended version.
From: http://googlewebmastercentral.blogspot. ... nalty.html
Don't create multiple pages, subdomains, or domains with substantially duplicate content.

Duplicate content on a site is not grounds for action on that site unless it appears that the intent of the duplicate content is to be deceptive and manipulate search engine results. If your site suffers from duplicate content issues, and you don't follow the advice listed above, we do a good job of choosing a version of the content to show in our search results.

This type of non-malicious duplication is fairly common, especially since many CMSs don't handle this well by default. So when people say that having this type of duplicate content can affect your site, it's not because you're likely to be penalized; it's simply due to the way that web sites and search engines work.
I realize there are no "penalties" unless Google interprets the similar content as being deceptive.  But, I don't want to leave it in the hands of Google LOL.  Especially, when I have to do everything I can to help my customer have the best chances in the search engines.

So, the canonical tag is another piece of the puzzle that shouldn't be dismissed because modules do not currently have a clear way of representing the URL of where their content is reached.

For now, I plan to test for the news, and other modules in use and not display a canonical link for them.  I'm sure there is a solution because I've been able to easily solve the unique News title challenge by reading Robert's and others posts.  I'm still learning how to modify PHP and smarty and only manage to do it to survive a project.
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
Russ
Power Poster
Power Poster
Posts: 813
Joined: Fri Nov 25, 2005 5:02 pm

Re: Assign the new SEO rel="canonical" link tag in HEAD of page

Post by Russ »

It is all very tricky and I guess up to who is designing / owning the site. Wether it is a good or bad thing is likely irrelevant if it is what Google and other search engines use?

I like to think that I can put code in the templates which will just work and with some provisos, the code I presented earlier does just that. Working with the latest version of Album and and a modified old Calendar (I've not started using the new one as I wrote some iCal stuff for the old one...) and it works fine with a bit of modification for both modules. Although it is probably only of use for Album if you have an 'Album Index' page, otherwise I would not bother.

When I get time I'll upload my local test site to the web so you can see what I mean.

The real solution is for version 2.0 of CMSMS to have consistent pretty url's and for all modules / plugins to follow the same pattern! That, I guess, means a fully featured documented module/plugin template for people to work with.
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: Assign the new SEO rel="canonical" link tag in HEAD of page

Post by JohnnyB »

calguy1000 wrote:

Code: Select all

<link rel="canonical" href="{$content_obj->GetURL()}">
nuf said
For some reason using the above writes errors to the server's error log like
PHP Fatal error:  Call to a member function GetURL() on a non-object in /home/lifesta1/public_html/tmp/templates_c/%%CB^CBC^CBC6D161%%template%3A17.php on line 19
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Assign the new SEO rel="canonical" link tag in HEAD of page

Post by calguy1000 »

You need to be running a 'supported' version of CMS Made Simple in order to use that.

i.e:  1.5.2 or 1.5.3 (at the time of writing this message).
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: Assign the new SEO rel="canonical" link tag in HEAD of page

Post by JohnnyB »

calguy1000 wrote: You need to be running a 'supported' version of CMS Made Simple in order to use that.

i.e:  1.5.2 or 1.5.3 (at the time of writing this message).
I should have mentioned that it is a site running 1.5.2.
I'll add it to a few other sites running 1.5.2 and check errors logs in a couple days.
----------------------------------------------

Cms Version: 1.5.2

Installed Modules:

    * CMSMailer: 1.73.14
    * FileManager: 0.4.3
    * MenuManager: 1.5.3
    * ModuleManager: 1.2.1
    * News: 2.9.2
    * nuSOAP: 1.0.1
    * Printing: 0.2.6
    * Search: 1.5.2
    * ThemeManager: 1.0.8
    * TinyMCE: 2.4.11
    * Captcha: 0.3.2
    * CGExtensions: 1.15
    * CGSimpleSmarty: 1.4
    * FormBuilder: 0.5.11
    * MovedPages: 0.1
    * Statistics: 0.9.1
    * SiteMapMadeSimple: 1.1.4
    * ImagePicker: 0.4
    * Download: 0.2b
    * DownloadManager: 0.8.4
    * FrontEndUsers: 1.6.2
    * SelfRegistration: 1.2.2
    * CustomContent: 1.5.2


Config Information:

    * php_memory_limit:
    * process_whole_template: true
    * max_upload_size: 100000000
    * default_upload_permission: 664
    * assume_mod_rewrite: true
    * page_extension:
    * internal_pretty_urls: false
    * use_hierarchy: true


Php Information:

    * phpversion: 5.2.6
    * md5_function: On (True)
    * gd_version: 2
    * tempnam_function: On (True)
    * magic_quotes_runtime: Off (False)
    * memory_limit: 32M
    * max_execution_time: 60
    * safe_mode: Off (False)
    * session_save_path: /tmp (1777)


Server Information:

    * Server Api: cgi
    * Server Db Type: MySQL (mysql)
    * Server Db Version: 5.0.67


----------------------------------------------
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: Assign the new SEO rel="canonical" link tag in HEAD of page

Post by JohnnyB »

calguy1000 wrote: You need to be running a 'supported' version of CMS Made Simple in order to use that.

i.e:  1.5.2 or 1.5.3 (at the time of writing this message).
The errors I see in the logs are only specific to the site I posted system information above.  I haven't seen errors on other 1.5.2 sites using it.
[05-Mar-2009 08:07:39] PHP Fatal error:  Call to a member function GetURL() on a non-object in /home/lifesta1/public_html/tmp/templates_c/%%CB^CBC^CBC6D161%%template%3A17.php on line 20
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
altryne
New Member
New Member
Posts: 2
Joined: Sun Dec 07, 2008 9:26 pm

Re: Assign the new SEO rel="canonical" link tag in HEAD of page

Post by altryne »

Im used to create one page like 'news' and set all the news using the detail page. The canonical URL will be the same for all news. This will confuse or limit the search engine approach on site. And for any other module it wont work too, since most of then uses the current page alias to display detail views.
Me too so I came up with was a little solution based on Calguys post here :

http://forum.cmsmadesimple.org/index.ph ... 646.0.html (Showing the News Article Title in the title when using the detailpage parameter.)
Go read it !

then :
I went and added to the top of my general template

Code: Select all

<link rel="canonical" href="{if isset($canonical)}{$canonical}{else}{$content_obj->GetURL()}{/if}" />
and then I just assign the $canonical variable in the template of each module I need.

for instance in my products detail template I set

Code: Select all

{capture name='cann' assign='canonical'}
{$gCms->config.root_url}/products/{$entry->id}/{$returnid}/{$entry->product_name}/
{/capture}
hope I explained myself clearly (if not feel free to ask)
Last edited by altryne on Fri Mar 20, 2009 11:12 pm, edited 1 time in total.
User avatar
dc2
Forum Members
Forum Members
Posts: 116
Joined: Tue Jun 02, 2009 8:21 pm

Re: Assign the new SEO rel="canonical" link tag in HEAD of page

Post by dc2 »

Because the UDT posted in here caused trouble on error-pages I edited it a little bit:

Code: Select all

global $gCms;

if ($gCms->variables['page_name'] !='') {
    $manager =& $gCms->GetHierarchyManager();
    $node =& $manager->sureGetNodeByAlias($gCms->variables['page_id']);

    if(isset($node)) {
        $content =& $node->getContent();
            if (isset($content) && is_object($content)) {
                if ($content->GetURL() != '') {
                    echo '<link rel="canonical" href="'.$content->GetURL().'" />';
	    }
        }
    }
}
Now the script tests, if the current page really exists before it retrieves the content from the tree.
Locked

Return to “Tips and Tricks”