Change record status: 
Introduced in branch: 

This change record has been updated based on

As a part of the new New Symfony-based routing system, the action link definitions are moving out of hook_menu() and into plugins implementing \Drupal\Core\Menu\LocalActionInterface. The primary discovery mechanism is YAML files following the naming pattern

A default implementation \Drupal\Core\Menu\LocalActionDefault is used unless another class is specified in the YAML file.

Drupal 7

function contact_menu() {
  $items['admin/structure/contact'] = array(
    'title' => 'Contact form',
    'description' => 'Create a system contact form and set up categories for the form to use.',
    'page callback' => 'contact_category_list',
    'access arguments' => array('administer contact forms'),
    'file' => '',
  $items['admin/structure/contact/add'] = array(
    'title' => 'Add category',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('contact_category_edit_form'),
    'access arguments' => array('administer contact forms'),
    'type' => MENU_LOCAL_ACTION,
    'weight' => 1,
    'file' => '',

Drupal 8

Local actions are defined in a YAML format, named after the module they are defined by ($modulename.links.action.yml). See Providing module-defined actions.

Yaml File

  route_name: contact_category_add
  title: 'Add category'
    - contact_category_list

Each local action is represented by a plugin with a definition from the YAML. Each local action definition contains four keys:
id: The machine name of the pluing
route_name: The machine name of the local action route.
title: The title of the local action. Will be passed on to t().
title_context: Optional context to pass on with the title to t().
appears_on: An array of route names for this action to be display on.

In order for a local action to be converted, both it and the path it appears on must first be converted to routes.
See #1971384: [META] Convert page callbacks to controllers for the list of issues and the WSCCI Conversion guide for instructions.

Note that the MENU_LOCAL_ACTION type did more than just present it as a local action, it also manipulated the breadcrumb trail and controlled which tabs appeared on its page. In order to preserve that behavior, a new constant was introduced, MENU_SIBLING_LOCAL_TASK.

Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other updates done


mkolar’s picture

Im wondering how to create links with parameters for example action link to "/admin/node/somebundle". Is it possible to set parameter node_type for this link?

route_name: node.add
title: 'Create new article'
- somewhere

levmyshkin’s picture

You can use route_parameters option, for example blog_post node type for node.add route:

  route_name: 'node.add'
  title: 'Add blog post'
    node_type: 'blog_post'
acidaniel’s picture

I´ve tried to implement the route_parameters but it is not working the link tasks is still displayed on others node types. Can you please confirm this?

levmyshkin’s picture

Yes, it works for me. I installed blog module:

Link task is displayed on /blog page to create a blog node.

taggartj’s picture

in mymodule.links.action.yml

  route_name: 'entity.webform.canonical'
  title: 'Some button text'
   # where you want it to sow up 
    - entity.entity_name.collection
    webform: contact

And remember to 'drupal cr'

it really Helps to use drupal console
drupal router:debug
or in my case drupal router:debug entity.webform.canonical

thank you @enzo !