Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Berdir on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Introduced in version:
8.0.0-beta4
Issue links:
Description:
To display a link with only a #fragment, the special route can be used.
Drupal 7
$fragment_only_url = url('', array('external' => TRUE, 'fragment' => 'fragment'));
Drupal 8
$fragment_only_url = \Drupal::url('<none>', [], ['fragment' => 'fragment']);
Impacts:
Module developers