Jump to content

Multiple logo link Henson template

Recommended Posts

Hi everyone,I am currently using the Henson template and i'm trying to make a multilingual site (I know the Henson template is not recommended for this but I don't want to change my template)Right now, my homepage is set to be the page where you select your language: DYLM.

Then i would want my logo to redirect to the homepage of each language (french and english): French and English.

I checked the related topics but they didn't work, do you have any idea?

Thanks a lot!

Link to comment
  • Replies 3
  • Views 778
  • Created
  • Last Reply

Final update:I finally did it! So this answer works only if you have a pattern for all pages that share the same attribute: for instance /en/you-page-title for any english page. It does also work regardless of the language, meaning you can do something similar for every type of page in your website, like for articles related pages, or for product related etc...So it goes like this:Go to settings > advanced > code injectionPaste this on your header:


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

and this on your footer:


<script>
if(window.location.href.indexOf('the_common_part_of_all_your_urls') >= 0) {$("img[alt='Your Site Name']").parent().attr("href", "/where_you_want_your_logo_to_go");
  };
if(window.location.href.indexOf('the_common_part_of_all_your_urls/') < 0) {$("img[alt='Your Site Name']").parent().attr("href", "/where_you_want_your_logo_to_go_otherwise");
  };
</script>

What it does is that the script on the footer will look what you put instead of thecommonpartofallyoururls on your website on the url of the active page and return a different number if it found the word or if it didn't find the word. For instance for my site I put:


<script>
if(window.location.href.indexOf('en/') >= 0) {$("img[alt='DYLM - Agence vidéo créative - Film & Motion Design - Lyon']").parent().attr("href", "/en/home");
  };
if(window.location.href.indexOf('en/') < 0) {$("img[alt='DYLM - Agence vidéo créative - Film & Motion Design - Lyon']").parent().attr("href", "/home");
  };
</script>

So when i'm on a page, when I click on my logo, it checks whether there is en/ on the url (for english pages) or not. If there is, "window.location.href.indexOf('en/') " returns one, and thus the logo brings me to /en/home which is the main page for all english pages, if not, it brings me to /home, the main page for french pages. This methods isn't restricted to 2 choices, you can do something like this:


<script>
if(window.location.href.indexOf('something_recurrent') >= 0) {$("img[alt=Your site name']").parent().attr("href", "/where_you_want_it_to_lead");
  };
if(window.location.href.indexOf('something_else_recurrent') >= 0) {$("img[alt='Your site name']").parent().attr("href", "/somewhere_else");
  };
if(window.location.href.indexOf(something_else_too') >= 0) {$("img[alt='Your site name']").parent().attr("href", "/somewhere_else_again");
  };
</script>

and so on, so here you go you can make your logo to lead to anywhere you want! Hope people will find this useful! You just have to manage your urls well so two pages where you don't want your logo to lead don't share one of the "somewhere_you_want_to_go" url and you're all set up!

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.