Skip to main content
this will not work unless it is identified as external and has a uri
Source Link

routing.yml are routes of your site, so they can not be external.

links.menu.yml are links that point to routes, so they can not be external.

To create external links, you need to create them as a menu link content entity in your hook_install() function.

Something like this:

  $menu_link = MenuLinkContent::create(array(
      'title' => 'Link title',
      'path''link' => 'http['uri' => 'https://www.googleexample.ch/'com'],
      'menu_name' => 'navigation',
      'weight' => 0,
      'external' => TRUE,
      'bundle' => 'menu_link_content',
    ));
  $menu_link->save();

routing.yml are routes of your site, so they can not be external.

links.menu.yml are links that point to routes, so they can not be external.

To create external links, you need to create them as a menu link content entity in your hook_install() function.

Something like this:

  $menu_link = MenuLinkContent::create(array(
      'title' => 'Link title',
      'path' => 'http://www.google.ch/',
      'menu_name' => 'navigation',
      'weight' => 0,
      'bundle' => 'menu_link_content',
    ));
  $menu_link->save();

routing.yml are routes of your site, so they can not be external.

links.menu.yml are links that point to routes, so they can not be external.

To create external links, you need to create them as a menu link content entity in your hook_install() function.

Something like this:

  $menu_link = MenuLinkContent::create(array(
      'title' => 'Link title',
      'link' => ['uri' => 'https://www.example.com'],
      'menu_name' => 'navigation',
      'weight' => 0,
      'external' => TRUE,
      'bundle' => 'menu_link_content',
    ));
  $menu_link->save();
Source Link
Berdir
  • 83.5k
  • 6
  • 161
  • 207

routing.yml are routes of your site, so they can not be external.

links.menu.yml are links that point to routes, so they can not be external.

To create external links, you need to create them as a menu link content entity in your hook_install() function.

Something like this:

  $menu_link = MenuLinkContent::create(array(
      'title' => 'Link title',
      'path' => 'http://www.google.ch/',
      'menu_name' => 'navigation',
      'weight' => 0,
      'bundle' => 'menu_link_content',
    ));
  $menu_link->save();