If a menu item has a submenu and I specify the hash symbol (#) in the Link field of such parent menu item in the admin panel, I receive empty url at the frontend and therefore if click by such link, I follow to the homepage.
Even if I use in my menu--main.html.twig
template the code like
{% set menu_item_url = item.url %}
{% if menu_item_url == '' %}
{% set menu_item_url = '#' %}
{% endif %}
<a href="{{ menu_item_url }}" ...
I still receive empty href=""
How to resolve the problem? I mean is there a way inside of templates? Of course, I know that I can resolve the problem with JS.
Note: I don’t mean an anchor, I just need # as parent item url if the item has a submenu.