How can I add a button next to the + Add Content button on /admin/content, in Drupal 8?

add content page


You have to provide mymodule.links.action.yml in your module.

This is an example from core for the Add content action button from your question:


  route_name: node.add_page
  title: 'Add content'
    - system.admin_content

Reference: Providing module-defined actions

  • Perfect! that works well, on a side note, do you know how to use that button to create form overlay for users to input data and then process that data? – harnamc Jan 23 '17 at 9:42

To further the answer above, if you want to theme the button you added from MODULE.links.action.yml you need to implement the following hook in you MODULE.module file:

function MODULE_menu_local_actions_alter(&$local_actions) {
  $local_actions['ROUTE.NAME']['options']['attributes'] = array(
    '#target' => '_blank'

The above hook will add the attribute target="_blank" to the link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.