Remove some characters instead of replacing them with hyphens, similar to the pathauto module

Created on 7 March 2025, about 1 month ago

Problem/Motivation

Heading IDs allow linking to headings, and therefore they appear in URLs. I would like to make the handling of the part after the # in the URL consistent with the part before the # in the URL. The part before the # is handled by the pathauto module in many cases, which supports skipping over characters like ' and ’ instead of replacing them with -. The part after # is not currently configurable to match that behavior.

Steps to reproduce

  1. Set up a pathauto alias for a node type, like article/[node:title].
  2. Create a node titled e.g. "My cat's fur"
  3. In the body of the node, create a heading like "My cat's fur"
  4. Save the node
  5. Observe that the full URL to the heading is article/my-cats-fur#my-cat-s-fur and not article/my-cats-fur#my-cats-fur

Proposed resolution

Allow similar configuration options to the pathauto module. Their configuration is a bit cumbersome and limited. I would propose somthing simpler: A text field where you can enter all characters that should be ignored.

A more flexible approach would be to allow the user to enter regular expressions and corresponding replacement patterns. That would be nice to have, but I don't currently have an urgent need for that.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΏπŸ‡¦South Africa rudolfbyker South Africa

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

Comments & Activities

  • Issue created by @rudolfbyker
  • πŸ‡ΏπŸ‡¦South Africa rudolfbyker South Africa

    Another use case is when I have "soft hyphens" https://symbl.cc/en/00AD/ in my headings. I would like them to be skipped instead of turned into real hyphens. Soft hyphens are nice for supporting long words on small screens, especially in headings, which tend to have big fonts.

  • πŸ‡ΏπŸ‡¦South Africa rudolfbyker South Africa

    A related thing that pathauto does, which may or may not be a separate issue from this one: It allows you to specify a list of stopwords, like 'a', 'the', etc. to skip when generating the ID.

Production build 0.71.5 2024