Default entity ID for _entity_view in routing.yml I've a custom content entity (created using Config pages module) which is used as a welcome screen / dashboard. Privileged super editors can edit those content entities, normal editors can only view it.

The config pages module itself does not provide routes to view modes (only to edit forms), so I used the core's generic _entity_view to create routes for the normal editors myself:

This is my_module.routing.yml

my_module.view_config_pages:
  path: '/admin/config_pages/{i_dont_want_no_parameter}'
  defaults:
    _entity_view: 'config_pages.full'
  requirements:
    _role: 'authenticated'
  options:
    _admin_route: true
    parameters:
        i_dont_want_no_parameter:
          type: 'entity:config_pages'


This works with URLs like /admin/config_pages/1, /admin/config_pages/2 etc... But I want to create nice, parameter-less, named routes to specific entity IDs. Something similar to my dummy-code below

my_module.view_welcome:
  path: '/admin/welcome'
  defaults:
    _entity_view: 'config_pages.full'
  requirements:
    _role: 'authenticated'
  options:
    _admin_route: true
    parameters:
        yeah_no_parameter:
          type: 'entity:config_pages'
          id: 1
my_module.view_stats:
  path: '/admin/stats'
  defaults:
    _entity_view: 'config_pages.full'
  requirements:
    _role: 'authenticated'
  options:
    _admin_route: true
    parameters:
        yeah_no_parameter:
          type: 'entity:config_pages'
          id: 2


Can this be done with _entity_view in YAML files without coding a custom controller?
The default ID can be set in the defaults section, here is an example:

my_module.view_dashboard:
  path: '/admin/dashboard/{my_entity_id}'
  defaults:
    _entity_view: 'my_custom_entity.full'
    my_entity_id: 123
  requirements:
    _role: 'authenticated'
    my_entity_id: ^[0-9]+
  options:
    _admin_route: true
    parameters:
      my_entity_id:
        type: 'entity:my_custom_entity'

my_module.view_stats:
  path: '/admin/stats/{my_entity_id}'
  defaults:
    _entity_view: 'my_custom_entity.full'
    my_entity_id: 456
  requirements:
    _role: 'authenticated'
    my_entity_id: ^[0-9]+
  options:
    _admin_route: true
    parameters:
      my_entity_id:
        type: 'entity:my_custom_entity'


This solution creates nice URLs without any controller.