diff --git a/core/modules/toolbar/src/Element/ToolbarItem.php b/core/modules/toolbar/src/Element/ToolbarItem.php
index e596687..3eef1d6 100644
--- a/core/modules/toolbar/src/Element/ToolbarItem.php
+++ b/core/modules/toolbar/src/Element/ToolbarItem.php
@@ -50,13 +50,15 @@ public function getInfo() {
    *   A renderable array.
    */
   public static function preRenderToolbarItem($element) {
-    // Assign each item a unique ID.
-    $id = Html::getUniqueId('toolbar-item');
+    // Assign each item an id based on their url.
+    if (isset($element['tab']['#url'])) {
+      $id = _toolbar_get_url_id($element['tab']['#url']);
 
-    // Provide attributes for a toolbar item.
-    $attributes = array(
-      'id' => $id,
-    );
+      // Provide attributes for a toolbar item.
+      $attributes = array(
+        'id' => 'toolbar-item-' . $id,
+      );
+    }
 
     // If tray content is present, markup the tray and its associated trigger.
     if (!empty($element['tray'])) {
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index 9a7914b..f2b5b7b 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -241,13 +241,7 @@ function toolbar_menu_navigation_links(array $tree) {
     // and behaviors to the menu links.
     $link = $element->link;
     $url = $link->getUrlObject();
-    if ($url->isExternal()) {
-      // This is an unusual case, so just get a distinct, safe string.
-      $id = substr(Crypt::hashBase64($url->getUri()), 0, 16);
-    }
-    else {
-      $id = str_replace(array('.', '<', '>'), array('-', '', ''), $url->getRouteName());
-    }
+    $id = _toolbar_get_url_id($url);
 
     // Get the non-localized title to make the icon class.
     $definition = $link->getPluginDefinition();
@@ -337,3 +331,22 @@ function _toolbar_get_user_cid($uid, $langcode) {
   return 'toolbar_' . $uid . ':' . $langcode;
 }
 
+/**
+ * Generates a HTML ID based on a Url object.
+ *
+ * @param \Drupal\Core\Url $url
+ *
+ * @return string
+ *   ID generated based on the Url object.
+ */
+function _toolbar_get_url_id($url) {
+  if ($url->isExternal()) {
+    // This is an unusual case, so just get a distinct, safe string.
+    $id = substr(Crypt::hashBase64($url->getUri()), 0, 16);
+  }
+  else {
+    $id = str_replace(array('.', '<', '>'), array('-', '', ''), $url->getRouteName());
+  }
+  return $id;
+}
+
