How to open URLs in new tab in config.yml of Jekyll / Github pages site?
Asked Answered
R

3

8

I'm self-taught/totally new to Jekyll and Github Pages and was wondering how to go about opening a URL in a new tab with markdown in the config.yml page.

This is the website theme I'm using. I want the last 'github' link to open in a new tab, instead of the default, which is opening in the current tab.

The _config.yml looks like this:

# # # # # # # # # # # # #
#   K i k o - p l u s   #
# # # # # # # # # # # # #

# Basic
name:         "Kiko Plus"

author:
facebook:         your-id
youtubeUser:      your-id
youtubeChannel:   your-id
twitter:    your-id
github:     your-id
stackoverflow:    your-id
quora:      your-id
linkedin:         your-id
pinterest:        your-id
googlePlus:       your-id
instagram:        your-id
reddit:     your-id
medium:     your-id
tumblr:     your-id
email:      [email protected]

copyright:
year:       2017
name:       Kiko

# Google-analytics
google-analytics:
id:         ""

# Disqus
disqus:
id:         "kiko-plus"

# URL
url:          "https://AWEEKJ.github.io" # the base 
hostname & protocol for your site
# url:          "http://localhost:4000" # use this url when 
you develop
baseurl:      "/Kiko-plus" # the subpath of your site


# http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
timezone:     Asia/Seoul
permalink:    /:year-:month-:day/:title/

# Pagination
paginate:     5
paginate_path:      /page:num/

# Markdown
markdown:     kramdown
kramdown:
input:      GFM

# Navigation
nav:
- name:     "About"
  url:      "/about"
- name:     "Archive"
  url:      "/archive"
- name:     "Tags"
  url:      "/tags"
- name:     "Github"
  url:      "https://github.com/AWEEKJ/Kiko-plus"

# Sass
sass:
sass_dir:         _sass
style:      :compressed

# Scopes
defaults:
-
  scope:
    path:         ""
    type:         "pages"
  values:
    layout:       "page"
-
  scope:
    path:         ""
    type:         "posts"
  values:
    layout:       "post"

# jekyll-seo-tag, 
gems:
- jekyll-seo-tag
- jekyll-paginate
- jekyll-admin

exclude:      [vendor]

To do this in any basic markdown post, naturally you'd do

[a link](http://example.com){:target="_blank"}

But since this link is in the site setup, that doesn't work. I've searched a ton and tried 5 or 6 different recommendations but to no avail.

Any ideas? Would be uber appreciated!!!!

Rendition answered 10/7, 2017 at 4:36 Comment(0)
W
5

You need to add target="_blank" to index.html line 12 as follow:

 <a href="{{ nav.url }}" target="_blank">{{ nav.name }}</a>
Winner answered 10/7, 2017 at 10:23 Comment(0)
G
9

I found a plugin that automatically sets any external URL to open in a new tab:

https://rubygems.org/gems/jekyll-target-blank

Add the following to your site's Gemfile

gem 'jekyll-target-blank'

and add the following to your site's _config.yml

plugins:
  - jekyll-target-blank

You may also need to run bundle install to install the new Gem

Gordan answered 27/1, 2021 at 1:53 Comment(1)
Worked like a charm for my Jekyll site! Thank you so much!Amelioration
W
5

You need to add target="_blank" to index.html line 12 as follow:

 <a href="{{ nav.url }}" target="_blank">{{ nav.name }}</a>
Winner answered 10/7, 2017 at 10:23 Comment(0)
C
2

{:target="_blank"} works for me:

[text](http://url){:target="_blank"}
Chalutz answered 23/9, 2022 at 15:46 Comment(1)
me also, ty for the response this is exactly what I was looking for :DHep

© 2022 - 2024 — McMap. All rights reserved.