Apparently the only template file to edit is for an individual search result, located at core/modules/search/templates/search-result.html.twig. So you can't move the search form after the results and style accordingly?

Just want to double check this.


Short answer. If you're looking for a twig template to move around the search form, no you can't.

Long answer. Drupal core search dynamically builds its search routes for all searchable entities then handles the page render via SearchController::view(). The controller view method only defines the theme functions/templates for the search results, not the search page as a whole.

If you wanted to move these around the render form & results elements, It's possible to override the search routes via a custom module so the _controller property points to a custom controller that extends SearchController and defines a view() method that does something like:

// in my custom search controller:
public function view(Request $request, SearchPageInterface $entity) {
  $build = parent::view($request, $entity);
  // @TODO: alter $build render array so form / results are re-ordered
  return $build;

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.