Using Menu Link Attributes Module Learn how to add attributes to links using Menu Link Attributes module. Composer composer require drupal/menu_link_attributes Module Menu Link Attributes