Use Linkit with core menu links

Last updated on
29 June 2025

It is possible to use Linkit's autocomplete widget with core menu links by adding a simple hook, as shown below:

function my_module_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
  if ($entity_type->id() === 'menu_link_content') {
    $fields['link']->setDisplayOptions('form', [
      'type' => 'linkit',
      'weight' => -2,
      'settings' => [
        'linkit_profile' => '<machine-name-of-your-desired-linkit-profile>',
        'linkit_auto_link_text' => <TRUE/FALSE>,
      ],
    ]);
  }
}

There are some known limitations of this, as discussed in https://www.drupal.org/project/linkit/issues/3393201, so use at your own risk.

Help improve this page

Page status: No known problems

You can: