How can I add items to the Admin Toolbar? In Drupal 8, I want to add a menu item to the Admin Toolbar with a submenu, with different links.

How can I do it?
You can add items to the admin toolbar in two ways:

As content:

In ui /admin/structure/menu/manage/admin

or in code:

$item = \Drupal\menu_link_content\Entity\MenuLinkContent::create([
  'link' =&gt; ['uri' =&gt; 'internal:/&lt;front&gt;'],
  'title' =&gt; 'Front Page',
  'menu_name' =&gt; 'admin',
]);
$item-&gt;save();


Or in static configuration files:

system.admin:
  title: Administration
  route_name: system.admin
  weight: 9
  menu_name: admin
system.admin_content:
  title: Content
  description: 'Find and manage content.'
  route_name: system.admin_content
  parent: system.admin
  weight: -10
system.admin_structure:
  route_name: system.admin_structure
  parent: system.admin
  description: 'Administer blocks, content types, menus, etc.'
  title: Structure
  weight: -8
system.themes_page:
  route_name: system.themes_page
  title: Appearance
  description: 'Select and configure themes.'
  parent: system.admin
  weight: -6


This is the start of system.links.menu.yml, which defines the admin menu as we know it from D8. You can add your own entries in mymodule.links.menu.yml.

Edit:

To add an item to the top row, use the hook mymodule_toolbar(). This is an example from the tour module:

/**
 * Implements hook_toolbar().
 */
function tour_toolbar() {
  $items = [];
  $items['tour'] = [
    '#cache' =&gt; [
      'contexts' =&gt; [
        'user.permissions',
      ],
    ],
  ];

  if (!\Drupal::currentUser()-&gt;hasPermission('access tour')) {
    return $items;
  }

  $items['tour'] += array(
    '#type' =&gt; 'toolbar_item',
    'tab' =&gt; array(
      '#type' =&gt; 'html_tag',
      '#tag' =&gt; 'button',
      '#value' =&gt; t('Tour'),
      '#attributes' =&gt; array(
        'class' =&gt; array('toolbar-icon', 'toolbar-icon-help'),
        'aria-pressed' =&gt; 'false',
      ),
    ),
    '#wrapper_attributes' =&gt; array(
      'class' =&gt; array('tour-toolbar-tab', 'hidden'),
      'id' =&gt; 'toolbar-tab-tour',
    ),
    '#attached' =&gt; array(
      'library' =&gt; array(
        'tour/tour',
      ),
    ),
  );
 return $items;
}