Automatically disable links to unpublished/non-existing internal entities

Created on 11 August 2025, 3 days ago

Problem/motivation

Large editorial teams inevitably create internal links that later become invalid (404) or point to unpublished content. This leads to broken UX for site visitors and valid errors in QA/SEO tools (e.g., Ryte) when internal links return 404.

Why address this in Linkit?

Linkit already manages references to internal entities and can reliably determine if a link points to internal content. Implementing this in Linkit allows consistent behavior across both inline links (editor) and link fields, using the same profile-based configuration.

Proposed resolution

Introduce an optional, profile-level setting hide_unpublished that, when enabled, renders links to non-existing or inaccessible (e.g., unpublished) internal entities as plain text instead of an anchor. Specifically:

  • Replace the anchor with a span.
  • Add a title: “The referenced content is not available.”
  • Add a special CSS class so such elements can be styled specifically.
  • Preserve attributes (except href).

This behavior should apply both to the text filter (for links in rich text) and the field formatter (for link fields).

Configuration

  • New boolean setting on ProfileInterface: hide_unpublished (default: FALSE for backward compatibility).
  • Profile-level scope avoids having to configure the behavior per text format or per field formatter.

Scope and non-goals

  • Only affects internal links that can be resolved (via Linkit data attributes or derivation).
  • External links (https://, mailto:, tel:) remain untouched.
  • Does not change access rules; it only adapts rendering based on entity existence/access.

Theming

  • New theme hook: linkit_unavailable_link with a Twig template (span output).
  • Preprocess merges URL attributes (except href) with provided attributes.
  • Site builders can theme .linkit-unavailable (e.g., dotted underline, help cursor).

UX/DX

  • Admin UI: A single checkbox in the Linkit Profile edit form: “Remove links to unpublished/non-existing entities”.
  • Frontend: Users see plain text with a tooltip (title) and optional styling via linkit-unavailable class.
  • Centralized behavior via profile ensures consistent results across editor and field formatter.

Backward compatibility

  • Default is OFF; existing sites see no behavior change.
  • An update path can initialize existing profiles to hide_unpublished = FALSE to be explicit.

Open questions for maintainers

  • Is <span> the preferred neutral markup for the fallback, or should an alternative be considered?
  • Should the title text be made configurable or is translation sufficient?
Feature request
Status

Active

Version

7.1

Component

Code

Created by

🇩🇪Germany mrshowerman Munich

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024