Search code examples
htmltumblr

How to manually set up tumblr theme, so link will open in new tab?


I have a Tumblr blog (http://tivonim.tumblr.com), and I want links to open in a new window. On the setting page this option is checked but it's still opening links in the same window. I want the people who click on the images will not leave my site. So, if the regular settings doesn't work, I think I may as well do it manually on the theme code myself. Problem is, as much as I try to add the "target:_blank" code on the code, it doesn't work. I be pasting it on the wrong place. I would also like the post credit to open in a new window. I tried to do it with the theme code, by adding the "target:_blank":

<div class="post_credit">
    למתכון המלא: {block:SourceLogo}<a href="{SourceURL}" target="_blank"><img src="{BlackLogoURL}" width="{LogoWidth}" height="{LogoHeight}" alt="{SourceTitle}" /></a>{/block:SourceLogo}
    {block:NoSourceLogo}{SourceLink}{/block:NoSourceLogo}
</div>

However, it still opens those links in the same window.

I heard it happens to other people, but none of them know how to work this out.


Solution

  • {block:NoSourceLogo}{SourceLink}{/block:NoSourceLogo} is your problem in that block. This makes a link without the target attribute.

    As per the block code from the Tumblr Guide this is what you're wanting:

    {block:ContentSource}
    <div class="post_credit">
        <a href="{SourceURL}" target="_blank">
            {lang:Source}:
            {block:SourceLogo}
                <img src="{BlackLogoURL}" width="{LogoWidth}" height="{LogoHeight}" alt="{SourceTitle}" />
            {/block:SourceLogo}
            {block:NoSourceLogo}
                {SourceTitle}
            {/block:NoSourceLogo}
        </a>
    </div>
    {/block:ContentSource}