Does anybody know exactly how to implement the hreflang tags to a multilanguage store? I guess it should be added to html_header.php, but what would the code look like?
I have the CEON URI module installed also.
Does anybody know exactly how to implement the hreflang tags to a multilanguage store? I guess it should be added to html_header.php, but what would the code look like?
I have the CEON URI module installed also.
Thanks for the link, however I am familiar with the tags, I was more referring to what the php code would look like.
Hmmmm......
example HTML
Same example using PHPCode:<a href="http://www.w3schools.com" hreflang="en">W3Schools</a>
I have a feeling that that this isn't quite what you are seeking though ???Code:<?php echo "<a href=\"http://www.w3schools.com\" hreflang=\"en\">W3Schools</a>" ; ?>
Cheers
RodG
It was something like that I was looking for. However the hreflang tag needs to be "assigned" to each zencart page; for multiple languages. I guess it couldn't be made with a few lines of code.
I still don't quite follow what you are trying to do or achieve, but I'm guessing that you want the hreflang=\"en\" to be replaced with a variable?
If so then something like......
......should probably do the trick.Code:<?php $myVar = "en" ; echo "<a href=\"http://www.w3schools.com\" hreflang=\".$myVar.\">W3Schools</a>" ; ?>
You will of course need to set the value of $myVar according to whatever condition it is you need it for though.
Perhaps if you could explain or demonstrate exactly what it is you are trying to do I/we may be able to offer more/better help.
Maybe this will also help?
https://support.google.com/webmaster...r/189077?hl=en
Cheers
RodG
Thanks, and sorry for not explaining clearly what it is Im trying to do. Here it is:
I have these two domains:
http://www.tronicore.co.uk/
http://www.tronicore.dk/
on the same server/same zencart installation. I am re-directing each language to the correct domain in htaccess.
The co.uk domain has all product and catagory pages like this example:
http://www.tronicore.co.uk/en/rs232-...422-converters
and all .dk product and catagory pages like this example:
http://www.tronicore.dk/da/rs232-rs485-konvertere
The CEON URL module adds the /en/ and /da/ sub-folders, and also the re-written URL of course.
Now I would like the hreflang tags to be assigned to all product and catagory pages in accordance to the link you mentioned (https://support.google.com/webmaster...r/189077?hl=en)
So for example the URL:
http://www.tronicore.co.uk/en/rs232-...422-converters
should contain:
<link rel="alternate" hreflang="en" href="http://www.tronicore.co.uk/en/rs232-rs485-rs422-converters" />
and the URL:
http://www.tronicore.dk/da/rs232-rs485-konvertere
should contain:
<link rel="alternate" hreflang="da" href="http://www.tronicore.dk/da/rs232-rs485-konvertere" />
All other product and category pages should follow this pattern.
Zen Cart 1.55a
in templates/YOUR_TEMPLATE/common/html_header.php
we have
This produces a hreflang for each of the OTHER languages, but not that of this actual page.Code:<?php // BOF hreflang for multilingual sites if (!isset($lng) || (isset($lng) && !is_object($lng))) { $lng = new language; } reset($lng->catalog_languages); while (list($key, $value) = each($lng->catalog_languages)) { if ($value['id'] == $_SESSION['languages_id']) continue; echo '<link rel="alternate" href="' . ($this_is_home_page ? zen_href_link(FILENAME_DEFAULT, 'language=' . $key, $request_type) : $canonicalLink . '&language=' . $key) . '" hreflang="' . $key . '" />' . "\n"; } // EOF hreflang for multilingual sites ?>
ie if you offer english and spanish on your site, the english page generates:
From what I read here,<link rel="alternate" href="https://www.YOURSITE.com/somepage?language=es" hreflang="es">
Concise
https://www.semrush.com/blog/7-commo...w-to-fix-them/
Detailed
https://moz.com/blog/using-the-corre...generator-tool
this is incomplete. There should also be a link to the self-same page:
I looked into this after receiving warning emails from Google Search Console,and this was the reason.<link rel="alternate" href="https://www.YOURSITE.com/somepage?language=es" hreflang="es">
<link rel="alternate" href="https://www.YOURSITE.com/somepage?language=en" hreflang="en">
So, this link requires commenting out:
<?php
// BOF hreflang for multilingual sites
if (!isset($lng) || (isset($lng) && !is_object($lng))) {
$lng = new language;
}
reset($lng->catalog_languages);
while (list($key, $value) = each($lng->catalog_languages)) {
//if ($value['id'] == $_SESSION['languages_id']) continue;
echo '<link rel="alternate" href="' . ($this_is_home_page ? zen_href_link(FILENAME_DEFAULT, 'language=' . $key, $request_type) : $canonicalLink . '&language=' . $key) . '" hreflang="' . $key . '" />' . "\n";
}
// EOF hreflang for multilingual sites
?>
Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...
Question:
You suggested commenting out:... But on a site with only one language, that will cause the <link rel=alternate hreflang=foo> to appear. Is that desirable when there's no other language, and the language is already specified in the <html> tag?Code://if ($value['id'] == $_SESSION['languages_id']) continue;
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
No. That's me not thinking outside my box.Is that desirable when there's no other language, and the language is already specified in the <html> tag?
Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...
Bookmarks