Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    Oct 2007
    Posts
    328
    Plugin Contributions
    0

    Default Implementing hreflang in a multilanguage store

    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.

  2. #2
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Implementing hreflang in a multilanguage store

    Quote Originally Posted by DML73 View Post
    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?

    http://www.w3schools.com/tags/att_a_hreflang.asp

  3. #3
    Join Date
    Oct 2007
    Posts
    328
    Plugin Contributions
    0

    Default Re: Implementing hreflang in a multilanguage store

    Thanks for the link, however I am familiar with the tags, I was more referring to what the php code would look like.

  4. #4
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Implementing hreflang in a multilanguage store

    Quote Originally Posted by DML73 View Post
    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
    Code:
    <a href="http://www.w3schools.com" hreflang="en">W3Schools</a>
    Same example using PHP
    Code:
    <?php 
    echo "<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 ???

    Cheers
    RodG

  5. #5
    Join Date
    Oct 2007
    Posts
    328
    Plugin Contributions
    0

    Default Re: Implementing hreflang in a multilanguage store

    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.

  6. #6
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Implementing hreflang in a multilanguage store

    Quote Originally Posted by DML73 View Post
    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 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......

    Code:
    <?php 
    $myVar = "en" ; 
    
    
    echo "<a href=\"http://www.w3schools.com\" hreflang=\".$myVar.\">W3Schools</a>" ; 
    ?>
    ......should probably do the trick.

    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

  7. #7
    Join Date
    Oct 2007
    Posts
    328
    Plugin Contributions
    0

    Default Re: Implementing hreflang in a multilanguage store

    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.

  8. #8
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,585
    Plugin Contributions
    30

    Default Re: Implementing hreflang in a multilanguage store

    Zen Cart 1.55a
    in templates/YOUR_TEMPLATE/common/html_header.php
    we have
    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 . '&amp;language=' . $key) . '" hreflang="' . $key . '" />' . "\n";
      }
      // EOF hreflang for multilingual sites
    ?>
    This produces a hreflang for each of the OTHER languages, but not that of this actual page.
    ie if you offer english and spanish on your site, the english page generates:
    <link rel="alternate" href="https://www.YOURSITE.com/somepage?language=es" hreflang="es">
    From what I read here,
    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:
    <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">
    I looked into this after receiving warning emails from Google Search Console,and this was the reason.

    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 . '&amp;language=' . $key) . '" hreflang="' . $key . '" />' . "\n";
    }
    // EOF hreflang for multilingual sites
    ?>
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  9. #9
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Implementing hreflang in a multilanguage store

    Question:
    You suggested commenting out:
    Code:
    //if ($value['id'] == $_SESSION['languages_id']) continue;
    ... 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?
    .

    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.

  10. #10
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,585
    Plugin Contributions
    30

    Default Re: Implementing hreflang in a multilanguage store

    Is that desirable when there's no other language, and the language is already specified in the <html> tag?
    No. That's me not thinking outside my box.
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v154 Multilanguage search
    By istilah in forum General Questions
    Replies: 1
    Last Post: 6 Apr 2017, 10:44 AM
  2. v151 Multilanguage store not displaying
    By vitaevalue in forum Addon Language Packs
    Replies: 2
    Last Post: 30 Oct 2013, 06:57 PM
  3. Multilanguage EZ-Pages
    By sumri in forum General Questions
    Replies: 0
    Last Post: 25 Sep 2008, 06:53 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR