How can I override the search result page title dynamically? In my Drupal 8 site, I am using the default search page. If I enter a keyword, for example article, the search result will be listed under Search result.
I want to change that to Search result for Article (keyword).
How can I achieve this?
Here comes an example snippet on how to override the page title by URL query:

/**
 * Implements hook_preprocess_HOOK().
 */
function MYTHEME/MYMODULE_preprocess_page_title(&amp;$variables) {

  $current_path = \Drupal::request()-&gt;getpathInfo();
  if ($current_path == '/search/node') {
    if (\Drupal::request()-&gt;query-&gt;has('keys')) {

      // Get the searched string.
      $keywords = \Drupal::request()-&gt;query-&gt;get('keys');

      // As of https://drupal.stackexchange.com/a/232304/15055 we probably
      // need to ensure the cache gets busted.
      $variables['#cache']['contexts'][] = 'url.query_args:keys';

      // Set the new title.
      $new_title = new \Drupal\Core\StringTranslation\TranslatableMarkup('Search result for Article (@keywords)', ['@keywords' =&gt; $keywords]);
      $variables['title'] = $new_title;
    }
  }
}