Forcing menu link to open in a new window?

Hello,

I would like to have one of my site menu links open a page in a new window/tab. I have found the documentation to make this work for embedded links on pages using Kirbytext (target: blank, popup: yes) but have found no way to apply this to an actual menu item. Any thoughts?

Thanks in advance.
Kurt

This is not Kirby specific but general HTML knowledge. Set the target attribute to “_blank”.

<a href="http://www.link.de" target="_blank">Visit this link</a>

Thank you for the quick response. This makes good sense to me but where (in which Kirby file) do I actually alter the code for this particular menu item?

Kurt

In your menu snippet, if you are using the Starterkit, that will be in /site/snippets/menu.php

Going to hijack this thread to ask if there’s a way to make the link button in a textarea field always generate markup that already has target: blank in it?

If you overwrite the link kirbytag (i.e. copy and modify and then save it under the same name in /site/tags), I guess that should work and you would not run into problems when updating the core, not tested though.

What Sonja wrote should work but please consider that it’s probably not the best thing to do to use target blank on everything. I’ve had good experience so far explaining to the client that it doesn’t always make sense.

You also might want to check out this post: Open link in new tab button for non-coders, there’s also a CSS-Tricks article on when to use or not to use target: _blank

1 Like

Yeah, I think what I would do if I had time would be to write a plugin that
adds a checkbox to the URL popup, asking if the link should open in a new
window.

That’s one feature of the Kirby Enhanced Textarea

1 Like