Open button links in new tab

I can’t figure out how to make an external link within a button open in a new tab, and I don’t see anyone else asking about this either. Anyone willing to help?

const externalLinks = document.querySelectorAll('a[href^="http"]:not([href^=""])');
externalLinks.forEach(link => { = '_blank';

The code above will open all links that don’t go to in a new link. (Update for your site, obviously.)

To target a single button, you’re going to need to figure out how to select it. Most ghost buttons are actually ‘a’ tags, so making that selector for example would let you select for just header card buttons. Or for buttons in the body of a post… or…


Hey that worked, Thank you so much!

1 Like