How to add pagination to programmatically rendered search result template
I tried with the search_result template and it worked, hope this helps you :


$output['prefix']['#markup'] = '&lt;h2&gt;Test page&lt;/h2&gt;';
//This sets up necessary global variables for the type =&gt; #pager
$page = pager_default_initialize(5, 2);
$render = [];
  $output[] = [
    '#theme' =&gt; 'search_result',
    '#result' =&gt; 's',
  ];
$pager = [
  '#type' =&gt; 'pager',
];
$output['suffix']['#markup'] = '&lt;/ol&gt;' . \Drupal::service('renderer')-&gt;render($pager);
return $output;



We just need to set up the global variables which help to process rendered array to output pagers items. And add a pager to the suffix.