Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Markdown: Link does not open in new tab

Solved by pamtbaau View solution

Started by Pedro M 6 years ago · 11 replies · 9160 views
6 years ago

Hi,

I try to write a cookies policy page in my site, and it does some curious. While with the other links to Firefox cookies policy page or Internet Explorer, open with **?target=_blank in a blank tab, with Google policy page doesn't happen the same.

I've write this:

https://support.google.com/chrome/answer/95647?hl=es&ref_topic=3421433?target=_blank

With this link, the page open in the current tab instead the new one.

For example, with the link to Mozilla Support works fine:

https://support.mozilla.org/es/products/firefox/privacy-and-security?target=_blank

What's wrong?

You can see it in grav.juanvillen.es

Thanks for your help.

last edited 02/26/20 by Pedro M
6 years ago

@pmoreno The link to Google is malformed.

TXT
<a href="https://support.google.com/chrome/answer/95647?hl=es&ref_topic=3421433%3Ftarget%3D_blank">

It should be:

TXT
<a href="https://support.google.com/chrome/answer/95647?hl=es&amp;ref_topic=3421433%3F" target="_blank">
6 years ago

Thanks. Your link is correct too.

6 years ago

Would you mind explaining why a link like

HTML
<a href="/path/to/page?target=_blank">Title</a>

should work? I haven't found any reference to this.

6 years ago

Ah, your answer refers to creating a link with the target attribute in Markdown...

TXT
[Link in new Tab](../some-page?target=_blank)

That wasn't clear to me...

6 years ago

This link doesn't work in markdown format. I think that is so because the link has two '?' character, but I'm not sure.

However, if I write the link like you say above, using the <a> tag, it works fine.

6 years ago Solution

@pmoreno Note the syntax of query strings:

  1. There can only be one ? in the url. It separates the path from the query string.
  2. Separate the second, third, and any subsequent parameters with &

Not working due to incorrect querystring:

HTML
Markdown : [My link](/path/to/page?param1=value1?target=_blank)
Generates: <a href="/path/to/page?param1=value1%3Ftarget%3D_blank">My link</a>

Working:

HTML
Markdown : [My link](/path/to/page?param1=value1&target=_blank)
Generates: <a href="/path/to/page?param1=value1" target="_blank">My link</a>

Kind request to edit and improve your question for clarity:

  • The question would be more clear if you explicitly showed the context of the urls shown: Show the entire markdown, or <a> you used.
  • And while you're at it, a better title could be "Markdown link not showing in new tab"
👍 1
6 years ago

Hi,

@pamtbaau, thaks again. At first of all, I'd like to inlcude the complete markdown code about the link to google page, referred in this post:

Code with <a> tag (works fine):

HTML
<a href="https://support.google.com/chrome/answer/95647?hl=es&amp;ref_topic=3421433%3F" target="_blank"> soporte de Google</a> o la Ayuda del navegador.

Code with your last solution (works fine, but it's more clear):

TXT
[soporte de Google](https://support.google.com/chrome/answer/95647?hl=es&amp;ref_topic=3421433%3F&target=_blank)

Finally, you're right when you say that the title of post isn't very clear, but I can't to change it now. If you want and you can change it, do it, no problem.

Thanks for all.

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 76 7 hours ago
General · by pamtbaau, 13 hours ago
1 47 12 hours ago
General · by Andy Miller, 1 day ago
0 44 1 day ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 40 5 days ago