Below is markup from SearchController.php file. I want to change the "Search results" from my search page and also markup.

File : \core\modules\search\src\Controller\SearchController.php

if (count($results)) {
  $build['search_results_title'] = array(
    '#markup' => '<h2>' . $this->t('Search results') . '</h2>',

I am afraid there is no way to fix this markup in theme file. In case you simply need to change spelling I suggest using string overrides as it is described in settings.php file.

$settings['locale_custom_strings_en'][''] = [ 
  'Search results' => 'New text',
| improve this answer | |
  • Where i have to write this function??? In which hook function?? – Deepak modi Dec 5 '16 at 4:35
  • So, i have to change in setting.php file. Is there any other way to do this?? – Deepak modi Dec 5 '16 at 5:16
  • Other way could be using Sting overrides module but unfortunately it is not ported to Drupal 8 yet. – ya.teck Dec 5 '16 at 5:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.