diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index 87414f0..387afa9 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -6,6 +6,7 @@
  */
 
 use Drupal\shortcut\Entity\Shortcut;
+use Symfony\Cmf\Component\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
 
 /**
@@ -457,7 +458,21 @@ function shortcut_preprocess_page(&$variables) {
   // shortcuts and if the page's actual content is being shown (for example,
   // we do not want to display it on "access denied" or "page not found"
   // pages).
-  if (shortcut_set_edit_access() && ($item = menu_get_item()) && $item['access']) {
+
+  // Load the router item corresponding to the current page.
+  $request = \Drupal::request();
+  $item = array();
+  if ($request->attributes->has('_legacy')) {
+    // @todo Remove once the old router system got removed.
+    $item = menu_get_item();
+  }
+  elseif ($route = $request->attributes->get(RouteObjectInterface::ROUTE_NAME)) {
+    $item['href'] = $request->attributes->get('_system_path');
+    // @todo What should be done on a 404/403 page?
+    $item['access'] = TRUE;
+  }
+
+  if (shortcut_set_edit_access() && ($item) && $item['access']) {
     $link = current_path();
     $query_parameters = drupal_get_query_parameters();
     if (!empty($query_parameters)) {
