2

How can I simply add "#" as a menu link in Drupal 8? I want to have:

<a href="#" ... output as a menu link.

Do I have to define my own route token akin to <nolink> and write a custom LinkGenerator class to handle that case?

i.e.:

elseif ($url->isRouted() && $url->getRouteName() === '<nolink>') {
      $generated_link = new GeneratedNoLink();
      unset($attributes['href']);
    }
elseif ($url->isRouted() && $url->getRouteName() === '<hashonly>') {
      $generated_link = new GeneratedLink();
      $attributes['href']= "#";
    }

Or is there an easier place to do this without disrupting the render pipeline?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.