In earlier versions of Drupal, there were categories of users which showed up as tabs on the user (profile) edit page, located at /user/{user}/edit. How can we define new tabs on this page in Drupal 8?

1 Answer 1


Tabs can be added to the user edit page as follows:

1) Define the route(s) for your tab(s) in [MODULE].routing.yml as normal:

  path: '/user/{user}/edit/something'
    _controller: '\Drupal\[MODULE]\Controller\SomeController::someSettingsTab'
    _title: 'Some Settings'
    _permission: 'some permission'
    user: \d+
        type: entity:user

2) In [MODULE].links.task.yml, add your tab(s) as you would primary tabs, except rather than using base_route, use parent_id, and set it to (somewhat unintuitively) the user edit form tab key, which is defined in user.links.task.yml as entity.user.edit_form (same as the route name):

  route_name: [MODULE].something.user_defaults
  parent_id: entity.user.edit_form
  title: Some Title
  weight: 10

3) You also need to define a tab for the user to switch back to, as tabs are only rendered if there are more than two tabs. In this case, we want to add a tab for the user edit form, using the user edit form route, again using the user edit form tab key:

  route_name: entity.user.edit_form
  parent_id: entity.user.edit_form
  title: Profile
  • 1
    Step 2 here says module.links.tasks.yml but I think the tasks should be singular: module.links.task.yml. I don't see any tasks.yml files in core/contrib.
    – greggles
    Jan 13, 2020 at 15:34
  • Updated accordingly. Thanks.
    – Jaypan
    Jan 13, 2020 at 15:53
  • I tried this with a Views created page. and trying to add to Admin Content page. So step 1 and 3 not required. Step 2: ssc_custom.admin_orphaned_pages: title: Orphaned pages route_name: view.orphaned_pages.page_1 parent_id: system.admin_content - cant add a return here.. ughh... this does add a secondary task but when going to that page, the primary/secondary tabs disappear.
    – liquidcms
    Feb 21, 2023 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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