A
A
Alexander Solovov2019-07-23 20:05:06
CMS
Alexander Solovov, 2019-07-23 20:05:06

There are two Canonical tags in the HTML code of the dynamic page. Is it correct? Which tag will take precedence?

On the site cms joomla 3, in the jshopping component.
The product is in two categories.
In one category, a product has one rel="canonical" tag

<link rel="canonical" href="http://сайт/категория-1/maslo-1l">

In another category, the same product has two rel="canonical" tags:
First tag
<link rel="canonical" href="http://сайт/категория-2/maslo-1l">

And the second tag, below, in the page code is rel="canonical"
<link rel="canonical" href="/категория-1/maslo-1l"/>

no site domain. starts with /
It turns out that where a product is repeated in another category, there are two rel="canonical" tags in the page code of this product.
On a page that has two "canonical" tags, which of the two tags takes precedence, top or bottom?
and is it correct at all when there are two canonical tags on the page
sample code
<!doctype html>
<html lang="ru-ru" dir="ltr">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <link rel="canonical" href="http://домен.ru/raznoe/indijskoe-kastorovoe-maslo-1l">
        <base href="http://домен.ru/raznoe/indijskoe-kastorovoe-maslo-1l" />
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta name="robots" content="noindex, nofollow" />
  <meta name="generator" content="Joomla! - Open Source Content Management" />
  <title>ььььььь</title>
  .....
        ....
        ....
  <link rel="canonical" href="/razprodazha/indijskoe-kastorovoe-maslo-1l"/>


    </head>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Evgeny Volf, 2019-07-23
@Wolfnsex

On a page that has two "canonical" tags, which of the two tags takes precedence, top or bottom?
and is it correct at all when there are two canonical tags on the page
According to the logic of HTML'a, the tag that is declared last will have priority (it must override all previous ones). But, since these tags are intended primarily for bots - there is an opinion that different bots can behave differently, primarily because according to the rules (if my memory serves me right) - "rel canonical" is indicated exactly in <head/>, therefore, there is a suspicion that bots in some cases can ignore the "lower" tag, and in some cases ignore the fact that the tag violates the rules and redefine the value ...
"Quite exactly", I think we can clarify either with support each individual search engine (or the author of the bot), or by the "scientific poke method" (that is, in fact).
UPD. PS I probably didn't watch well the first time...<head/>, with a higher probability (according to the rules of HTML) the second one will work.

D
Decadal, 2017-11-07
@vanesxl

You don't have an autoload file, I suspect. Well, you can either include all the classes manually (good luck) or install the dependency via composer:
Use a dependency manager for your projects. In the repository you listed in the instructions, composer is actually the only suggested installation method.
More info:
php.net/manual/en/language.oop5.autoload.php
https://getcomposer.org/doc/00-intro.md

L
Lone Ice, 2017-11-07
@daemonhk

Regarding autoload (instead of Composer):

function myAutoload ($class) {
    $class=str_replace("\\",DIRECTORY_SEPARATOR,$class);
    include($_SERVER['DOCUMENT_ROOT']."/" . $class . ".php");
}
if (!empty($client)) {
    foreach($client->_classmap as $class){
       spl_autoload_register("myAutoload");
    }
}
//$client - класс, в котором есть зависимости

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question