For a Drupal 8 EU Cookie Compliance patch I needed a way to add an anchor link as a default menu item programmatically in .menu.yml
- title: "Anchor example"
- description: "Scroll to top on the current page"
- url: "internal:#top"
See my addition in documentation: https://www.drupal.org/docs/drupal-apis/menu-api/providing-module-defin… Thanks to the comments in https://drupal.stackexchange.com/questions/229376/non-clickable-menu-it… and https://drupal.stackexchange.com/questions/280665/how-to-add-a-nolink-m… which helped me a lot to find this solution.