I am using Joomla! 2.5.17 Stable version of Joomla. I have created a component that uses a code to add canonical URL:
Code: Select all
$document = JFactory::getDocument();
$document->addCustomTag("some custom code");
$document->addCustomTag("<link rel=\"canonical\" href=\"$theCorrectCanonical\" />");
Since i have a lots of views it is defined in each view for my-view, my-view2 etc.
It was working fine. The canonical link was added properly. Event if i had cache on.
And lately i have disabled modules i didn't need anymore. So i disabled them and website was working fine after this.
Suddenly i have discovered Google marks my pages as non-canonical.
After looking at the code of website i have noticed that the HTML head looks like this:
Code: Select all
some custom code
<link rel="canonical" href="correct-url" />
<link rel="canonical" href="url-of-a-page-i-visited-second-ago" />
I have tried to search for a solution, but didn't find any. Also i have noticed that when i disable cache in config with:
Code: Select all
public $caching = '0';
Index.php of my template looks like this:
Code: Select all
<?php
/**
* @version $Id: index.php 21518 2011-06-10 21:38:12Z chdemko $
* @package Joomla.Site
* @subpackage Templates.beez_20
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
$resourcesVersion = "1.1";
$this->setGenerator('');
// No direct access.
defined('_JEXEC') or die;
// check modules
$showRightColumn = ($this->countModules('position-3') or $this->countModules('position-6') or $this->countModules('position-8'));
$showbottom = ($this->countModules('position-9') or $this->countModules('position-10') or $this->countModules('position-11'));
$showleft = ($this->countModules('position-4') or $this->countModules('position-7') or $this->countModules('position-5'));
if ($showRightColumn==0 and $showleft==0) {
$showno = 0;
}
JHtml::_('behavior.framework', true);
// get params
$color = $this->params->get('templatecolor');
$logo = $this->params->get('logo');
$navposition = $this->params->get('navposition');
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$templateparams = $app->getTemplate(true)->params;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >
<head>
<jdoc:include type="head" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
some stylesheets embedded directly
some scripts embedded directly
a meta tag embedded directly
</head>
Do you have any clues i could follow to find what is the issue here?