Direkt zum Inhalt

Devbits

Kleine Code-Schnipsel aus unserem Alltag mit Drupal, PHP und DevOps: Problem, Lösung, Code.

05.10.2026 | Michael Ebert

Enable the admin theme for your custom route

You are registering a new route and would like it to be displayed using the administrative theme.

my_module.edit:
  options:
    # Enable the admin theme for this route.
    _admin_route: TRUE

Issue:

You are registering a new route and would like it to be displayed using the administrative theme.

Solution:

To enable the admin theme on your custom route, you can add it as option in your routing.yml file. But keep in mind that this will only work for users that have permission to use the admin theme!

See the Drupal documentation for further information.