Target blank option in Menu Dawn Theme

Solved
vwade15
Shopify Partner
4 1 5

Hello Team,

 

I have my store using the Dawn theme where I have couple menu items that I would like to open in a new tab when the customer clicks on them, for example the "Blog" link or the social media icons (Facebook, TikTok, etc.). Is it possible in the next update to give us the option to select the target to blank when creating our menu items in Online Store - Navigation?

Accepted Solutions (2)
EcomGraduates
Shopify Partner
588 48 73

This is an accepted solution.

Yes, it is possible to have menu items in your Shopify store open in a new tab. Currently, there is no option to select the target to blank when creating menu items in the Shopify admin panel, but you can use a workaround by adding some custom code to your theme.

 

Find the section of code that defines your menu, which will likely look something like this:

{% for link in linklists.main-menu.links %} <a href="{{ link.url }}">{{ link.title }}</a> {% endfor %}

Modify the code to include the "target=_blank" attribute, like this:

{% for link in linklists.main-menu.links %} <a href="{{ link.url }}" target="_blank">{{ link.title }}</a> {% endfor %}

banned

View solution in original post

vwade15
Shopify Partner
4 1 5

This is an accepted solution.

Hello,

 

Thank you for your reply. Yes, I have done the workaround before the first post. I use an if else statement to test the title of the link before adding target to it because I only want some of my menus to open in a new tab, not all of them. I just want it to be an option in the Shopify admin panel for people who don't want to play with the code.

 

This is my code in "footer.liquid"

 

{

{%- for link in block.settings.menu.links -%}
<li>


<!-- wv - test menu - Add target="_blank" so they open in a new tab when the customer clicks on them-->
<!--
<a
href="{{ link.url }}"
class="link link--text list-menu__item list-menu__item--link{% if link.active %} list-menu__item--active{% endif %}"
>
{{ link.title }}
</a>
-->

{%- if link.title == "Blog" or link.title == "Facebook" or link.title=="Instagram" or link.title=="TikTok" -%}
<a
href="{{ link.url }}" target="_blank"
class="link link--text list-menu__item list-menu__item--link{% if link.active %} list-menu__item--active{% endif %}"
>
{{ link.title }}
</a>
{%- else -%}
<a
href="{{ link.url }}"
class="link link--text list-menu__item list-menu__item--link{% if link.active %} list-menu__item--active{% endif %}"
>
{{ link.title }}
</a>
{%- endif -%}
<!-- wv end test menu -->


</li>
{%- endfor -%}

View solution in original post

Replies 3 (3)
EcomGraduates
Shopify Partner
588 48 73

This is an accepted solution.

Yes, it is possible to have menu items in your Shopify store open in a new tab. Currently, there is no option to select the target to blank when creating menu items in the Shopify admin panel, but you can use a workaround by adding some custom code to your theme.

 

Find the section of code that defines your menu, which will likely look something like this:

{% for link in linklists.main-menu.links %} <a href="{{ link.url }}">{{ link.title }}</a> {% endfor %}

Modify the code to include the "target=_blank" attribute, like this:

{% for link in linklists.main-menu.links %} <a href="{{ link.url }}" target="_blank">{{ link.title }}</a> {% endfor %}

banned
vwade15
Shopify Partner
4 1 5

This is an accepted solution.

Hello,

 

Thank you for your reply. Yes, I have done the workaround before the first post. I use an if else statement to test the title of the link before adding target to it because I only want some of my menus to open in a new tab, not all of them. I just want it to be an option in the Shopify admin panel for people who don't want to play with the code.

 

This is my code in "footer.liquid"

 

{

{%- for link in block.settings.menu.links -%}
<li>


<!-- wv - test menu - Add target="_blank" so they open in a new tab when the customer clicks on them-->
<!--
<a
href="{{ link.url }}"
class="link link--text list-menu__item list-menu__item--link{% if link.active %} list-menu__item--active{% endif %}"
>
{{ link.title }}
</a>
-->

{%- if link.title == "Blog" or link.title == "Facebook" or link.title=="Instagram" or link.title=="TikTok" -%}
<a
href="{{ link.url }}" target="_blank"
class="link link--text list-menu__item list-menu__item--link{% if link.active %} list-menu__item--active{% endif %}"
>
{{ link.title }}
</a>
{%- else -%}
<a
href="{{ link.url }}"
class="link link--text list-menu__item list-menu__item--link{% if link.active %} list-menu__item--active{% endif %}"
>
{{ link.title }}
</a>
{%- endif -%}
<!-- wv end test menu -->


</li>
{%- endfor -%}

Claudee
Visitor
1 0 0

This is not a real solution to the request. As it states, the requirement specifies targeting blank only specific links, not all of them.
I still looking for a solution.