How do you get the current destination URL query parameter in Twig? Does anyone know to how to get the drupal destination in twig file?
At the moment I an getting the destination parameters in a preprocess function.
// Get destination params.
$variables['destination_params'] = \Drupal::destination()-&gt;getAsArray();

Then in the twig file:
&lt;p&gt;
You can try &lt;a href=&quot;{{ path('user.login', {}, {'query': destination_params}) }}&quot;&gt;logging in&lt;/a&gt; to see if you have access.
&lt;/p&gt;

Thanks!
You can use path() function with '&lt;current&gt;' pseudo URI to generate current page relative URL.
For example:
{# in hard-coded path (bad practice) #}
&lt;a href=&quot;/user/login?destination={{ path('&lt;current&gt;') }}&quot; class=&quot;btn btn-sm btn-primary icon-before&quot;&gt;&lt;i class=&quot;fad fa-sign-in&quot;&gt;&lt;/i&gt; Sign-In&lt;/a&gt;

{# more proper twig-like way #}
&lt;p&gt;
You can try &lt;a href=&quot;{{ path('user.login', {}, {'query': {'destination': path('&lt;current&gt;') }}) }}&quot;&gt;logging in&lt;/a&gt; to see if you have access.
&lt;/p&gt;

More about Drupal's twig built-in functions here: https://www.drupal.org/docs/theming-drupal/twig-in-drupal/functions-in-twig-templates