How to add anchor links in CKEditor 5

03 Nov 2025 | By Drupal support team
Anchor link icon
03 Nov 2025 | By Drupal support team

At the moment, CKEditor 5 in Drupal doesn’t include a built-in “anchor” button, but you can create anchor links manually using a simple workaround.


Step-by-Step: Create an Anchor Link

  1. Type your heading or section title — for example:
    Bookmark 1
  2. Place your cursor right after the heading (you can add a single space after it).
  3. Select the space and click the Link button in the toolbar.
  4. In the Link URL field, enter:
    #bookmark1
  5. Expand the Advanced settings (▼) and set the ID field to match your anchor name:
    bookmark1
  6. Click the checkmark to save the link.

Your link and section will now work together — the link “#bookmark1” will jump to the section where the element has the ID “bookmark1”.


Example

If you create three links at the top of your page:

Bookmark 1 | Bookmark 2 | Bookmark 3

…and assign corresponding IDs (bookmark1, bookmark2, bookmark3) to your section headers, clicking a link will smoothly jump to that section within the same page.

Screenshot of how to add anchor links in CKEditor 5
Example setup of an anchor link in CKEditor 5.
  • This is a temporary workaround until anchor functionality is reintroduced in CKEditor 5 for Drupal.
  • You can use any ID name, but it must match exactly between the link (e.g. #bookmark1) and the element ID (bookmark1).