I would like to open links in a new tab or window where we the links created via [link](http://www.example.com) and starting with http/https… But also avoid this behavior for the links that we created via {{< ref >}} flags.
Something doesn’t make sense. The link render hook is not called when doing this:
[foo]({{< ref "foo" >}})
You would have to do this:
[foo]({{% ref "foo" %}})
Let us see your code
Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.
If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.
If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.
I have already asked you to share a repository that demonstrates the problem.
Since you are either unable or unwilling to do that, here is a repository with a working example.
git clone --single-branch -b hugo-forum-topic-34000 https://github.com/jmooring/hugo-testing hugo-forum-topic-34000
cd hugo-forum-topic-34000
hugo server
Then visit http://localhost:1313/post/test/
Without looking at your code I have no way of knowing what you are doing wrong. But you are doing something wrong.