11

I use CKEditor in Drupal 8. I want that every link will open in a new tab of browser. I want that the code look like this

    <a href="#" target="_blank">my link</a>

But if I use the link Button in editor I do not have choice for target blank. I only can fill in the url of link and the code looks like this

    <a href="#">my link</a>

Any idea what I have to do for changing this?

20

D8 Editor Advanced link module

Enhances the link Dialog in D8 CKEditor. Allows to define the following attributes:

  • title
  • class
  • id target
  • rel

enter image description here

5

If you want every link to open in a new window, it'd be better to not use the Editor Advanced Link module, but instead add a filter to your text format that sets target=_blank on every <a>.

  • How can I do that: "add a filter to your text format that sets target=_blank on every <a>"? I don't see that kind of filter when edit a text format. – Saulius Sep 22 '16 at 14:08
  • 1
    You'd have to create one. Unless drupal.org/project/extlink already does this, it sounds like it might. – Wim Leers Sep 24 '16 at 11:42
5

You can use the Linkit module and add a "target" attribute at admin/config/content/linkit/manage/default/attributes/add

It has two options:

  • Selectlist with predefined targets.

Dialog with options

  • Simple checkbox to allow links to be opened in a new browser window or tab.

Dialog with checkbox

  • I prefer Linkit because it provides an easy interface for internal linking with wysiwyg editors by using an autocomplete field. – Sébastien Gicquel Jan 5 '18 at 12:01
  • Linkit 8.x-5.x has removed support for link attributes. The module's page advises: "If you are in need for link attributes, please see D8 Editor Advanced link", as posted in chosen solution here. – Nick Hope Jun 14 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.