Image link to open new page in new window


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?


You can try this:

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.


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

It got compiled to HTML:

<p><a href="" target="_blank">Text</a></p>

Based on answer

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.

Side note on dependencies

Here is my Gemfile.

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

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.