Open external link in new tab

Open external link in new tab

In theme.liquid, insert the following before </body>

<script>
document.addEventListener('DOMContentLoaded', function() {
var 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';
}
}
});
</script>
    • Related Articles

    • Make parent link clickable

      Snippets > header-mega-menu.liquid (l.19-25) Parentlink {%- assign parentlink = link.links[0] -%} <a href="{{ parentlink.url }}" title="{{ parentlink.title }}"> <span {%- if link.child_active %} class="header__active-menu-item" {% endif %} > {{- ...
    • Reduce menu link padding in the footer

      In the footer section, add the following in the custom css: .list-menu__item--link { padding: 0px; }
    • Video carousel with product link

      {% doc %} @prompt I want a video carousel block with the followings: - unlimited videos, preferably adding thru the section - product thumbnail with product link, when click it goes to product page - desktop column: 3,4,5 - mobile column: 1,2 - ...
    • Hide menu link in mega menu when product counts = 0

      In header-mega-menu.liquid, search {%- for childlink in link.links -%} Add the following below: {%- if childlink.object and childlink.object.products_count == 0 -%} {%- continue -%} {%- endif -%} Then, search {%- for grandchildlink in childlink.links ...
    • Highlighting one menu link with a distinct color

      In the header, add in custom css as followings: a[href^="/pages/contact-us"] {color: #33ff00 !important;}