In my custom module I want to define a new tab associated with nodes. I have my own custom route file with the required definitions and a Links file to make sure the new route will be displayed as a node tab.

Everything works as planned, except that... The content of my custom page is wrapped in admin theme, not the website frontend theme.

I have found other threads where people ask the opposite question: 'how to enforce admin theme'? In those situations, it looks like that by setting '_admin_route: TRUE' on the route file will do the trick. More on this here:

How to set admin theme for a route?

I thought I would be able to achieve what I want by setting '_admin_route: FALSE', but it doesn't work. Frontend theme doesn't show, admin theme still kicks in.

This is my modulename.route.yml file:

  path: '/node/{node}/custom-tab'
    _title: 'Custom tab Content'
    _controller: '\Drupal\bti\Controller\MyTabController::pageContent'
    _node_operation_route: TRUE
    _admin_route: FALSE
        type: entity:node
    _permission: 'access content'
    _custom_access: '\Drupal\bti\Controller\MyTabController::access'

And this is my modulename.links.task.yml file:

  route_name: modulename.node.custom_tab
  base_route: entity.node.canonical
  title: 'Custom tab'
  weight: 50
        - 'my-custom-class'

So, to sum up: how can I make the new custom page in a node tab be displayed with theme defined for the frontend, not the admin theme? Thank you!

Edit 1

Is it possible that what I am looking for is the attribute '_theme' inside 'options'? It is marked as TODO here: https://www.drupal.org/docs/8/api/routing-system/structure-of-routes.


1 Answer 1


The _node_operation_route option respect the Use the administration theme when editing or creating content, if you want to explicitly disable admin theme for this node-related page don't use _node_operation_route

The _node_operation_route option overrides _admin_route https://api.drupal.org/api/drupal/core%21modules%21node%21src%21EventSubscriber%21NodeAdminRouteSubscriber.php/function/NodeAdminRouteSubscriber%3A%3AalterRoutes/8.8.x

  • Ahhhh, great, man, fantastic and many thanks. I simply removed _node_operation_route and _admin_route from my route file and all works as expected. Commented Dec 6, 2019 at 14:49

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.