All Projects → keithmifsud → jekyll-target-blank

keithmifsud / jekyll-target-blank

Licence: MIT license
Automatically opens external links in a new browser for Jekyll Pages, Posts and Docs.

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to jekyll-target-blank

jekyll-gzip
Generate gzipped assets and files for your Jekyll site at build time
Stars: ✭ 34 (-60.47%)
Mutual labels:  jekyll-plugin, rubygem
turkish banks
All Turkish Banks and Their Branches
Stars: ✭ 28 (-67.44%)
Mutual labels:  rubygem
jekyll-portfolio-generator
Generates a portfolio/project pages (including related projects) out of data files
Stars: ✭ 55 (-36.05%)
Mutual labels:  jekyll-plugin
sidekiq queue metrics
Records stats of each sidekiq queue and exposes APIs to retrieve them
Stars: ✭ 29 (-66.28%)
Mutual labels:  rubygem
itunes receipt validator
Validate iTunes Transaction and Unified style receipts with local decoding and remote validation.
Stars: ✭ 38 (-55.81%)
Mutual labels:  rubygem
honey format
Makes working with CSVs as smooth as honey.
Stars: ✭ 13 (-84.88%)
Mutual labels:  rubygem
ocr space
Free Online OCR for Ruby - Convert images to text
Stars: ✭ 62 (-27.91%)
Mutual labels:  rubygem
git statistics
A gem that allows you to get detailed statistics of a git repository.
Stars: ✭ 62 (-27.91%)
Mutual labels:  rubygem
strings-case
Convert strings between different cases.
Stars: ✭ 65 (-24.42%)
Mutual labels:  rubygem
cli-rubygem
Command line interface for interacting with Civo's cloud API
Stars: ✭ 15 (-82.56%)
Mutual labels:  rubygem
ruby terraform
A simple Ruby wrapper for invoking terraform commands.
Stars: ✭ 92 (+6.98%)
Mutual labels:  rubygem
jekyll-swagger-ui
A Jekyll plugin to integrate Swagger UI into Jekyll site
Stars: ✭ 16 (-81.4%)
Mutual labels:  jekyll-plugin
premonition
Premonition 4 is a Jekyll extension that makes it possible to add block-styled side content to your site. For example summaries, notes, hints or warnings.
Stars: ✭ 41 (-52.33%)
Mutual labels:  jekyll-plugin
strings-ansi
Handle ANSI escape codes in strings
Stars: ✭ 17 (-80.23%)
Mutual labels:  rubygem
jekyll-font-awesome-sass
A plugin to add Font Awesome to your Jekyll site
Stars: ✭ 24 (-72.09%)
Mutual labels:  jekyll-plugin
dkdeploy-typo3-cms
dkdeploy-typo3-cms provides functionality for fully automated deployments targeting TYPO3 CMS applications
Stars: ✭ 16 (-81.4%)
Mutual labels:  rubygem
material-sass
A rubygem of Material Design for Bootstrap 4
Stars: ✭ 55 (-36.05%)
Mutual labels:  rubygem
jekyll-instagram
A Jekyll plugin for displaying your recent Instagram photos
Stars: ✭ 24 (-72.09%)
Mutual labels:  jekyll-plugin
ruby-sdk
♦️ Ruby SDK to use the IBM Watson services.
Stars: ✭ 45 (-47.67%)
Mutual labels:  rubygem
dry-logger
[WIP] Logging library
Stars: ✭ 16 (-81.4%)
Mutual labels:  rubygem

Jekyll Target Blank

Jekyll Target Blank Logo

Automatically adds a target="_blank" rel="noopener noreferrer" attribute to all external links in Jekyll's content plus several other automation features for the external links. Read more here

Gem Version Build Status

Installation

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

Note: if jekyll --version is less than 3.5 use:

gems:
  - jekyll-target-blank

Usage

By default. all anchor tags and markdown links pointing to an external host, other than the one listed as the url in Jekyll's _config.yml will automatically be opened in a new browser tab once the site is generated.

All the links in pages, posts and custom collections are included except for __plain text links.

Examples

HTML

The following HTML anchor tag:

<a href="https://google.com">Google</a>

will be replaced with:

<a href="https://google.com" target="_blank" rel="noopener noreferrer">Google</a>

..unless your website's URL is google.com 😉

Markdown

[Google](https://google.com)

will be generated as:

<a href="https://google.com" target="_blank" rel="noopener noreferrer">Google</a>

Configuration

No custom configuration is needed for using this plugin, however, you can override some default behaviours and also make use of some extra features as explained in this section.

Override the default behaviour

You can override the default behaviour and only force external links to open in new browser if they have a CSS class name included with the same value as the one listed in the Jekyll _config.yml file.

To override this automation, add an entry in your site's config.yml file, specifying which CSS class name a link must have for it to be forced to open in a new browser:

target-blank:
    css_class: ext-link

With the above setting, only links containing the class="ext-link" attribute will be forced to open in a new browser.

Automatically add additional CSS Classes

You can also automatically add additional CSS classes to qualifying external links. This feature is useful when you want to add CSS styling to external links such as automatically displaying an icon to show the reader that the link will open in a new browser.

You can add one or more space separated CSS classes in _config.yml like so:

target-blank:
    add_css_classes: css-class-one css-class-two

The above example will add class="css-class-one css-class-two" to the generated anchor tag. These CSS class names will be added in addition to any other existing CSS class names of a link.

Override the default rel attributes

For security reasons, rel="noopener noreferrer" are added by default to all the processed external links. You can override adding any of the noopener and noreferrer values with the following entries in your site's _config.yml file.

To exclude the noopener value:

target-blank:
   noopener: false

To exclude the noreferrer value:

target-blank:
   noreferrer: false

To exclude both noopner and noreferrer values:

target-blank:
   noopener: false
   noreferrer: false

Adding additional rel attribute values

You can add additional rel="" attribute values by simply specifying them in your site's _config.yml file.

target-blank:
    rel: nofollow

or even more than one extra:

target-blank:
    rel: nofollow

Note:

The rel setting overrides other default rel attribute values. Therefore, (for example), if you exclude the noopener value and then add it to the rel property, it will still be added. The following config:

target-blank:
    noopener: false
    rel: noopener

will output:

<a href"https://some-external-website.what" target="_blank" rel="noreferrer noopener">Some link</a>

Support

Simply create an issue and I will respond as soon as possible.

Contributing

  1. Fork it
  2. Create your feature branch (`git checkout -b my-new-feature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Testing

rake spec
# or
rspec

Credits

The logo illustration was Designed by Freepik. Thank you ❤️

Legal

This software is distributed under the MIT license.

© 2018 - Keith Mifsud https://keith-mifsud.me and approved contributors.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].