Have your say in Community Polls: What was/is your greatest motivation to start your own business?

How to create a menu item linking to an external site?

Solved

How to create a menu item linking to an external site?

PaulF
Excursionist
13 1 0

Hi,

Is there a way I can create a menu item that links to an external site in a new window?

Thanks,

Paul

Accepted Solution (1)
PaulF
Excursionist
13 1 0

This is an accepted solution.

Hooray! You are a genius my man.

Thank you so much.

Paul

View solution in original post

Replies 12 (12)

Elevateab
Excursionist
13 1 0

Yea i think you could do that in the lliquid code if its not possible in the theme editor. Let me know if you need help with that

Test your shops products and pages to find the variation that brings in the most revenue with Elevate AB Testing. https://apps.shopify.com/elevate-ab-testing
PaulF
Excursionist
13 1 0

Hi,

Thanks, yes I do need some help. I just need that link to open in a new window.

Paul

Elevateab
Excursionist
13 1 0

Ok which theme are you using?

Test your shops products and pages to find the variation that brings in the most revenue with Elevate AB Testing. https://apps.shopify.com/elevate-ab-testing
PaulF
Excursionist
13 1 0

Brooklyn

Elevateab
Excursionist
13 1 0

Heres a quick fix throw this at the top of your theme.liquid file {%- if page.handle contains "test-page" -%}<script>window.open("https://apps.shopify.com/elevate-ab-testing", '_blank'); window.history.back();</script> {%- endif -%}

 

Replace the url i have with whatever url you want to open externally. 

Test your shops products and pages to find the variation that brings in the most revenue with Elevate AB Testing. https://apps.shopify.com/elevate-ab-testing
PaulF
Excursionist
13 1 0

That doesn't work, maybe because the link is to a url outside of the shopify site.

Elevateab
Excursionist
13 1 0

Hey sorry i forgot to mention what i did was i made another page and added it to the navigation. When i click on that it has a url, i put the name of that url where test-page is. What you have to do is replace test-page with your url. Just the part after the yourstore.com/. Let me know if you still have any issues

Test your shops products and pages to find the variation that brings in the most revenue with Elevate AB Testing. https://apps.shopify.com/elevate-ab-testing
PaulF
Excursionist
13 1 0

Sorry I guess I am not getting it.

Here is the site https://heartofadragonmoviestore.com/

The BLOG in the menu goes to a blogger site, I would like that to open in a new window.

Elevateab
Excursionist
13 1 0

So i checked it out, how did you get it to go to the other link. Did you use what i sent or did you do it a different way?

Test your shops products and pages to find the variation that brings in the most revenue with Elevate AB Testing. https://apps.shopify.com/elevate-ab-testing
PaulF
Excursionist
13 1 0

A different way, I just put the url in the menu link box in the built in menu list. Now I want to open it in a new window.

 

Screen Shot 2021-01-08 at 6.25.54 PM.png

tim
Shopify Partner
3911 394 1435

Paul, try this.

Open your theme.js (or theme.js.liquid)  asset  and at the very bottom of the file add this code:

/* make all external links open in new window/tab */
$( function(){
  $('a[href^="https://"]')							// select all links wit non-realtive path
 	.not('[href^="'+ window.location.origin + '"]')	// except for those on same site
    .attr('target', "_blank")						// make em open in new window
});

 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
PaulF
Excursionist
13 1 0

This is an accepted solution.

Hooray! You are a genius my man.

Thank you so much.

Paul