Use following condition to check for homepage
{% if app.request.attributes.get('_route') == 'homepage' %}
instead of
{% if path(app.request.attributes.get('_route')) == '/' %}
Explanation:
When you are accessing an URL which required parameter(s), your code in if statement path(app.request.attributes.get('_route'))
generates the error. As your home page route is defined as homepage
, only checking the _route
attribute will be enough to determine that you are accessing the homepage.
Happy coding!!