# Image link to open new page in new window

**URL:** <https://talk.jekyllrb.com/t/image-link-to-open-new-page-in-new-window/5283>\
**Category:** Help\
**Created:** [November 27, 2020, 3:19pm UTC](https://talk.jekyllrb.com/t/image-link-to-open-new-page-in-new-window/5283 "2020-11-27T15:19:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![robbertl](https://avatars.discourse-cdn.com/v4/letter/r/e68b1a/32.png) [@robbertl](https://talk.jekyllrb.com/u/robbertl)\
**Post date:** [November 27, 2020, 3:19pm UTC](https://talk.jekyllrb.com/t/image-link-to-open-new-page-in-new-window/5283/1 "2020-11-27T15:19:52Z")

</div>

Hello,

I am new to Jekyll and need some help with an image link issue.

I want to use an image as a link in a post or page, when clicked on to bring the viewer to another website in a new window.

Can anybody advise how this is done?

Thanks

---

<div class="post-metadata">

**Author:** ![jhvanderschee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jhvanderschee/32/583_2.png) [@jhvanderschee](https://talk.jekyllrb.com/u/jhvanderschee)\
**Post date:** [November 27, 2020, 9:48pm UTC](https://talk.jekyllrb.com/t/image-link-to-open-new-page-in-new-window/5283/2 "2020-11-27T21:48:45Z")

</div>

You can try this: [https://jekyllcodex.org/without-plugin/new-window-fix/](https://jekyllcodex.org/without-plugin/new-window-fix/)

---

<div class="post-metadata">

**Author:** ![MichaelCurrin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/michaelcurrin/32/2340_2.png) [@MichaelCurrin](https://talk.jekyllrb.com/u/MichaelCurrin)\
**Post date:** [November 30, 2020, 11:32am UTC](https://talk.jekyllrb.com/t/image-link-to-open-new-page-in-new-window/5283/3 "2020-11-30T11:32:44Z")

</div>

You probably use Kramdown already (it’s the default parser for Jekyll but you can override in your config)

Which means you can use some Kramdown syntax on your Jekyll site - no plugins needed.

```auto
[Text](https://example.com){:target="_blank"}

```

I tested it locally on my Jekyll site and it works create.

It got compiled to HTML:

```auto
<p><a href="https://example.com" target="_blank">Text</a></p>

```

Based on answer [https://stackoverflow.com/a/4705645](https://stackoverflow.com/a/4705645)

You just have to use that on each link that must be external. The includes solution in the previous answer uses JS to rewrite your external links. Which is also fine can be inserted in your `head` tag of your `default.html` so you can use it anywhere. It just depends on JS being enabled and working on the user’s browser.

---

<div class="post-metadata">

**Author:** ![MichaelCurrin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/michaelcurrin/32/2340_2.png) [@MichaelCurrin](https://talk.jekyllrb.com/u/MichaelCurrin)\
**Post date:** [November 30, 2020, 11:35am UTC](https://talk.jekyllrb.com/t/image-link-to-open-new-page-in-new-window/5283/4 "2020-11-30T11:35:17Z")

</div>

## Side note on dependencies

Here is my Gemfile.

```auto
gem "jekyll", "~> 3.9"
gem "kramdown-parser-gfm", "~> 1.1.0"

```

> <https://github.com/MichaelCurrin/jekyll-blog-demo/blob/master/Gemfile#L3-L4>

On Jekyll 3.9 - the site will not serve unless you explicitly install this kramdown gem. For Jekyll \<3.9 and for \>=4, it is implied as subdependency so can be omitted from your Gemfile.
