Menu Link Attributes is a great Drupal 8 module that allows you to add attributes to your menu links. Let's see how you can set the attributes programmatically.
Quick tip on how to set date fields programmatically in Drupal 8.
Creating a menu link programmatically in Drupal 8 is easy. You have to provide four values, link title and Uri, menu name for which you want to create a menu link, and optionally you can provide a link weight.