Jump to content

Changing the link of my header logo in my 2 langage website

Recommended Posts

Site URL: https://www.staciedollx.com/

Hey there, i'm working for someone wensite and i was able first to redirect my header logo to my english section, but since i have also a french section i don't know how to redirect only to the french section. Here is the code i use for the english version. 

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

<script>$(document).ready(function () {
         $(".header-title-logo a[href]").attr("href", "https://www.staciedollx.com/en/home");
       });
</script>

 

Is there a way that my website recognize i'm on my french version, so it would redirect to my french page ? 

 

Also i have a fake cover page (version 7.1) as my home page.

 

Thanks 

Link to comment
  • Replies 12
  • Views 403
  • Created
  • Last Reply

Replace your script, store somewhere for safe keeping or comment out, then add the following.

<script>

  $( document ).ready ( function ( ) {
  
    // change site logo link to home pages of multi-language site
    
    let languageHomeUrlSlug = {
    
      '/en' : '/home',
      '/es' : '/moi'
      
      }
      
    // do not change anything below, there be the borg here
    
    let languageUrlSlug = location.pathname.substring ( 0, 3 );
    
    if ( ! Object.keys ( languageHomeUrlSlug ).includes ( languageUrlSlug ) ) return; 
    
    let href = languageUrlSlug + languageHomeUrlSlug [ languageUrlSlug ];
    
    $( '.header-title-logo a, .header-mobile-logo a' ).attr ( 'href', href );
    
    } );
    
  </script>

Let us know how it goes.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment
7 hours ago, jaunevermeer said:

It works but now my menu is all there, english and french ! 

 

Anyway i could have my french menu only when i select the french website ?

My code doesn't do anything to the menus. I saw no effect on the menus when I ran it. I suggest removing my code temporarily to see if that helps the issue.

It sounds like you changed the code in PIED DE PAGE which broke the code that was controlling which language version of the menu is seen.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment
7 hours ago, jaunevermeer said:

Wich one should i change, the header or footer ? Thanks ! 

Replace the code you posted...

On 12/16/2020 at 5:36 PM, jaunevermeer said:

<script>$(document).ready(function () {
         $(".header-title-logo a[href]").attr("href", "https://www.staciedollx.com/en/home");
       });
</script>

...in EN-TETE.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.