Get argument from current URL in twig to generate a link with that argument
well if you are making a custom block then you are probably doing something like this .... 

 $build = [];
 $build['#theme'] = 'your_template',
 return $build;


and then in you hook_theme().

 hook_theme() {
  return [
   'your_template' =&gt; [
     'render element' =&gt; 'children',
     'template' = 'your-templante-name',
    ],
  ];
 }


you don't need to pre prossess the block at all just make sure the block is not being cached aka add this to your block plugin. 

see How to prevent a block from being cached?

public function getCacheMaxAge() {
  return 0;
}


then in your block function :

 $search_query = \Drupal::request()-&gt;get('search_api_fulltext');
 $build = [];
 $build['#theme'] = 'your_template',
 $build['#search_query'] =  $search_query,
 return $build;
....


 hook_theme() {
  return [
   'your_template' =&gt; [
     'render element' =&gt; 'children',
     'template' = 'your-templante-name',
     'variables' =&gt; [
       'search_query' =&gt; NULL,
     ],
    ],
  ];
 }


then in your twig template 

{% if search_query %}
  do what you want here {{search_query}}
{% endif%}