Drupal Linkit Module

Published Sep 8, 2021
Updated Oct 12, 2021
By Simon

Linkit module is possibly the most used alternative to Drupal's default link functionality. After using CKEditor Entity Link for a year without issue I decided to switch out the CKEditor Entity Link module for Linkit because I wanted to build a better linking functionality and cut back on the number of linking icons in the CKEditor toolbar. To read more about that you can read a better linking set-up for Drupal.

With that little ramble out of the way let's look at Linkit Module starting with some benefits and then set up and configuration.

Image
Linkit auto-suggest feature in action

The Benefits of Linkit module

  1. Allows easy search of internal URLs with auto-suggestion functionality. This functionality is also provided by CKEditor Link Module.
  2. Integrates with the default linking functionality meaning no need to add a new icon to the toolbar. This means one linking solution for both internal and external links.
  3. It uses system URL paths such as /node/36 and switches them out to use the canonical URL such as /my-cool-article using a filter that works on render. This is nice as you can change URL alias names of linked content and the links still work1. To find out more about setting up pretty URLs be sure to read Drupal SEO must-haves.

Old URLs don't become broken but if you move the site be aware
Even with the above functionality, the node/36 URL is hardcoded into the site so if you are developing on a development server in a directory this will be saved in the database. So I would suggest not entering masses of URLs otherwise you will need to go back in and change the URLs when you go live.

Info

Actively maintained Yes, 110,000+ sites report using it.
Requires No extra requirements

https://www.drupal.org/project/linkit

Basics

The module's page on Drupal.org is thorough so if you want more details other than those already provided in the benefits section I suggest you check the above link out. Below is a step by step guide to get you set up.

Installation

Install Linkit either using the UI or composer. Since there are no extra requirements it can be installed in the normal way. If you are unsure how to install a module please read Installing Drupal Modules where I cover both UI and composer methods.

Once the module is installed you need to enable it on the CKEditor for each text format and editor profile you want to use it. You can do that in the text formats and editors section.

Enable Linkit for the Text Formats that will use it

  1. Visit Text formats and editors
    Manage > Administration > Configuration > Content authoring > Text formats and editors
    /admin/config/content/formats
  2. Select a text format that has CKEditor 

    Image
    text formats and ckeditor overview page in drupal
  3. On your chosen text format under the CKEditor plugin settings, there is a Drupal link section where you need to check Linkit to enable it. 

    Image
    ckeditor linkit plugin settings
  4. Select the Linkit profile. There is only one called default and is perfect for a small site.
  5. Enable the filter to enable the URL alias instead on the node/# url paths 

    Image
    enable filter linkit url converter
    Updates links inserted by Linkit to point to entity URL aliases.
  6. Click Save configuration.

Repeat for any other Text formats you what to enable Linkit for.

That's it Linkit is now ready to use for the chosen text format and related CKEditor. If you want to restrict what can be linked to, add a new matcher or create a new profile you can do that on the Linkit profiles pages.

Modify or Create a new Linkit Profile

On install, there is a default profile and it works nicely so there is no need to do anything.

However, if you do want to modify the default Linkit profile or add a new profile you can do that on the Linkit profiles page. This allows you to set up different Linkit profiles that can then be used for different text formats and user roles. This might be useful on a large site and also if you want to integrate a new type of matcher. This topic is an advanced topic and the default profile is sufficient but if you want to check it out it can be found in the Content authoring section.

Manage > Administration > Configuration > Content authoring > Linkit > Linkit Profiles
/admin/config/content/linkit

Things you can change in the default Profile with the content matcher are:

  1. The meta that is shown in the auto-suggestion window when adding a new link in the content.
  2. Restrict the content type.
  3. Group suggestions by bundles (content types)
  4. Limit search result, this is set to 100 and is fine for most sites.
  5. Include unpublished nodes. Be careful with this as users would need permissions to visit the links so if they don't have the permissions you get a restricted content message, not a good user experience.

One thing you may want to do is restrict what content types or bundles that can be referenced. For example, your site may have a content type for internal use that can not be viewed by anonymous users and therefore it would be best to remove it from Linkit. Let's take a look at modifying the default Linkit profile.

Modify the Default Profile in Drupal Linkit Module

Image
linkit profiles top page with default linkit profile
  1. Click on Edit Profile
  2. Click on Manage matchers
  3. Click on Edit for the Content matcher
  4. Modify the Setting
  5. Save Changes

So that's it you now have a new profile to use on the text format and editor page for each text format.

By having this fine controlled functionality built into Linkit and using text formats you can make adding and managing content a nice experience by removing unnecessary clutter in CKEditor. This is one of the reasons why you may want to choose Drupal as your CMS.

Final Thoughts

Linkit is a simple but powerful module and Linkit would be a recommended addition to all Drupal sites to enhance linking functionality. If you want more details on why I recommend this module over CKEditor Entity Link please check  A Better Linking Configuration For Drupal CKEditor to help you decided.

Thanks for reading and I hope you found what you needed. I will write about making Drupal easy and also making beautiful front-ends for your websites whether Drupal or static. If that interests you please sign up for my newsletter.

See you soon.