Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Link Purpose Icons

938 sites Security covered Drupal 9–11
View on drupal.org

This project enhances accessibility by automatically adding icons and screen reader hints to links that navigate users to external sites, open in new windows, send emails, download files, initiate calls, or launch third-party applications. It helps users understand link behavior before clicking.

The Link Purpose JS library attaches icons and screen reader hints to links that open external sites, open new windows, send emails, download documents, make calls and open third-party apps.

Accessibility guidelines encourage giving users advance warning if clicking a link causes this type of change of context.

The library includes a default set of icons:

If you want to bring your own icons, the module config page has settings for CSS class-based icon libraries (e.g. Font Awesome Icons). Icons that involve changing the HTML, such as inline SVG and Material Icons, can be implemented using custom JS in your theme; reference "Community Documentation" below.
 

Features

  1. Icons automatically match link color, even when modified on :hover or :focus, or by system high contrast settings.
  2. The last word of each link is wrapped into a span with the icon, preventing line breaks between the text and the icon.
  3. Links can be excluded by page region or any CSS selector.
  4. Icons and the visually-hidden text for screen readers are in separate containers, allowing designers to remove the icon or the text if context makes one or the other redundant.
  5. For multilingual sites, the visually-hidden text for screen readers passes through Drupal's translation system.
  6. Dynamically inserted (AJAX) links, as well as links inside Shadow DOM / Web Components can be marked as well.

The library accepts numerous parameters for its markup. By default, it will convert this:

<a href="https://example.com">
    EXAMPLE LINK
</a>

to this:

<a href="https://example.com" class="link-purpose link-purpose-external" aria-describedby="link-purpose-description-1">
    EXAMPLE
    <span class="link-purpose-spacer"> </span> 
    <span class="link-purpose-nobreak link-purpose-last-word">
        LINK
        <span class="link-purpose-icon link-purpose-external-icon" aria-hidden="true" title="Link is external">
            <svg ...></svg>
        </span>
        <span class="link-purpose-text" id="link-purpose-description-1">
             Link is external
         </span>
    </span>
</a>

Much of that is helper classes for themers:

  • The link itself receives identifying classes, as well as an aria-describedby connection to descriptive text.
  • A spacer is added before the last word, so it can be sized or hidden.
  • The last word is wrapped in a span with the icon, to allow for fine control of text/icon wrapping.
  • The icon wrapper has its own classes, and a title tag for mouseovers.
  • The descriptive text for screen readers is visually hidden by default, but can be separately targeted by CSS as needed.

 

Post-Installation

It should work out of the box with no configuration overrides at all.

Optionally: set domains you want considered internal in absolute URLs on the configuration page. By default the site's base URL will be used.

 

Additional Requirements

None. It's vanilla JS.

 

Editoria11y Accessibility Checker.

 

Similar projects

The External Links module can also mark email and external links. Key differences:

  • The Link Purpose module adds five additional categories (document, telephone, file download, app and new window), allows themes to insert custom link categories, adds line break prevention, and has no jQuery dependency.
  • The External Links module can create "You are leaving the site" popup windows on external links.

The Link Purpose configuration page has instructions for settings that will emulate External Links' markup to assist with migration.

 

Supporting this Module

Help testing right-to-left languages would be appreciated.

 

Community Documentation

The Link Purpose JS library docs detail additional settings that can be injected by themes or modules -- e.g., adding additional categories of links or using HTML based icon libraries.

To use these parameters:

  1. Check the box on the configuration page "Attach library then stop; theme will mark links."
  2. Create a duplicate of the module JS that sends parameters to the library.
  3. Customize the parameters coming from drupalSettings or add your own.

 

Project meta

Depends on

Dependencies of the latest stable release

  • user Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
8
Tracked since
Apr 2025
Latest release
1 month ago
Releases (12 mo)
4
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.0.23 Stable 9–11 Jul 27, 2026
1.0.22 Stable 9–11 Jul 8, 2026
1.0.21 Stable 9–11 Apr 7, 2026
1.0.20 Stable 9–11 Sep 9, 2025
1.0.19 Stable 9–11 Jul 15, 2025
1.0.18 Stable 9–11 May 28, 2025
1.0.17 Stable 9–11 May 27, 2025
1.0.16 Stable 9–11 Apr 4, 2025