Liquid, JavaScript, themes, sales channels
Hey Shopify Community!
I am looking for the code change necessary for external links to open in a new window for the Dawn Theme. Shopify currently has released documentation for their "vintage themes" not on Online Store 2.0 and it does not apply to Dawn.
Any help is greatly appreciated.
Thanks!
Solved! Go to the solution
This is an accepted solution.
You can add target="_blank" for links, refer https://www.w3schools.com/tags/att_a_target.asp .
It will help you to customize whether or not to add an open new window for the links.
Or go to assets/global.js file and paste this at the bottom of the file:
https://i.imgur.com/dArdGFW.png const links = document.links; for (let i = 0, linksLength = links.length ; i < linksLength ; i++) { if (links[i].hostname !== window.location.hostname) { links[i].target = '_blank'; links[i].rel = 'noreferrer noopener'; } }
This is an accepted solution.
Awesome thanks!
I actually realized that if I followed Shopify's help doc here: https://help.shopify.com/en/manual/online-store/themes/os/customize/open-external-links-in-new-tab
And paste the code they provide in that guide into the asset > global.js file it works!
Hey, @SamW111.
Thank you for reaching out and posting this question!
I understand you're looking to modify the Dawn theme, so that external links can open in a new window. While there isn't a documentation or tutorial for this with Online store 2.0, this may be something that our Theme Support team can help you with. If your store is subscribed to a plan, then you're eligible to use the complimentary design time included with your subscription for modifying your theme. While we’re not able to provide account-specific support via the Shopify Community at this time, we’d be happy to continue assisting you through live chat, email, or callback. Please visit the Shopify Help Center and log in to your account to create a support request.
I'd love to know if our Theme Support team can help you with this. Keep me posted!
Elias | Social Care @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
This is an accepted solution.
You can add target="_blank" for links, refer https://www.w3schools.com/tags/att_a_target.asp .
It will help you to customize whether or not to add an open new window for the links.
Or go to assets/global.js file and paste this at the bottom of the file:
https://i.imgur.com/dArdGFW.png const links = document.links; for (let i = 0, linksLength = links.length ; i < linksLength ; i++) { if (links[i].hostname !== window.location.hostname) { links[i].target = '_blank'; links[i].rel = 'noreferrer noopener'; } }
This is an accepted solution.
Awesome thanks!
I actually realized that if I followed Shopify's help doc here: https://help.shopify.com/en/manual/online-store/themes/os/customize/open-external-links-in-new-tab
And paste the code they provide in that guide into the asset > global.js file it works!
It works. Thank you.
This works ! Thanks
Worked! Thanks!
Thanks a lot!!!
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024