Redirect to referring page after form submission
You can't rely on the referrer header, because clients can refuse to provide one. For this use case Drupal has implemented a query parameter destination. Configure the webform with a default Confirmation URL, like &lt;front&gt;, and then add the current url as destination query string to links pointing at the webform.

For example add a feedback link to nodes:

use Drupal\Core\Url;

/**
 * Implements hook_preprocess_HOOK() for node templates.
 */
function mymodule_preprocess_node(&amp;$variables) {
  $variables['content']['feedback'] = [
    '#type' =&gt; 'link',
    '#title' =&gt; t('Feedback'),
    '#url' =&gt; new Url(
      'entity.webform.canonical',
      ['webform' =&gt; 'feedback'],
      ['query' =&gt; ['destination' =&gt; Url::fromRoute('&lt;current&gt;')-&gt;toString()]]
    ),
    '#cache' =&gt; ['contexts' =&gt; ['url.path']],
  ];
}


This overrides the configured confirmation URL and returns to the referring page after the webform is submitted.

In a page template you don't need the cache context and you can use this Twig only solution, as @PaulH has suggested:

href="/form/feedback?destination={{ path('&lt;current&gt;') }}"