I'm not certain if I'm over-complicating something or just missing something or other.

Essentially, and in addition to a separate admin view of my custom entities, I want to assign a URL to them at the root of the site (i.e. /entity01).

I tried creating a URL property, but getting a route to respond to that is proving challenging. I tried adding a route like:

  path: '/{entity_url}'
    _controller: '\Drupal\my_module\Controller\MyController::view'
    _title: 'Hello'
        type: entity_url
    _permission: 'access content'

I have a custom a custom parameter converter set up as in:


... and in the convert method, I can use an injected service to load my entity, etc. But in the applies method, I would like to see if it even matches any of my entities and return true or false appropriately, but the applies method doesn't seem to have the value of the URL parameter like the convert method does.

And even if I solve that, the above example only works with a path like:

path: '/my/{entity_url}'

If I remove the /my it doesn't work - I assume because it is conflicting with another route?

Thanks for any help!

  • 2
    I believe this was asked recently, but your route cannot start with a parameter like that.
    – Kevin
    Commented Feb 7, 2019 at 21:52

1 Answer 1


I think you can do this with the pathauto (path alias?) module. Go to the Admin -> Config -> Search / Metadata -> URL Aliases. In the settings tab, enable your custom entity type.

When you edit them, you should have a URL field added. You can also use the patterns to define default paths if you want.

I did a quick test with an ECK custom entity and it worked.

  • Wow ... I can't believe I didn't look there. I really thought I'd have to put the URL alias field in some manner myself, but it took care of it. Only 2 more issues I'll have: I really wanted a separate (or additional) view of the entity from the admin view (I suppose I can give this one a different theme) and I have some sub-pages I'll need off of this (i.e. /{entity_url}/subpage. I may have a lead on the latter issue. Thanks! Commented Feb 7, 2019 at 23:35

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.