diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index 9dbbc20..d43c0e7 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -11,6 +11,7 @@
  */
 
 use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Core\Link;
 use Drupal\Core\Render\Element;
 
 
@@ -43,12 +44,11 @@ function template_preprocess_menu_local_task(&$variables) {
 
   $link['localized_options']['set_active_class'] = TRUE;
 
-  $variables['link'] = array(
-    '#type' => 'link',
-    '#title' => $link_text,
-    '#url' => $link['url'],
-    '#options' => $link['localized_options'],
-  );
+  /** @var \Drupal\Core\Url $url */
+  $url = $link['url'];
+  $options = $url->getOptions();
+  $url->setOptions($options + $link['localized_options']);
+  $variables['link'] = Link::fromTextAndUrl($link_text, $url);
 }
 
 /**
diff --git a/core/modules/system/templates/menu-local-task.html.twig b/core/modules/system/templates/menu-local-task.html.twig
index ec02a8d..fd56a3a 100644
--- a/core/modules/system/templates/menu-local-task.html.twig
+++ b/core/modules/system/templates/menu-local-task.html.twig
@@ -7,6 +7,9 @@
  * - attributes: HTML attributes for the wrapper element.
  * - is_active: Whether the task item is an active tab.
  * - link: A rendered link element.
+ * - link.url: The link URL.
+ * - link.text: The link text.
+ * - link.
  *
  * Note: This template renders the content for each task item in
  * menu-local-tasks.html.twig.
