I have a view page with url and machine id search

I need to add a custom page.html.twig for that specific view page so that it does not affect the rest pages.

How can I implement it?

I tried adding page--search.html.twig but it did not work.

2 Answers 2


Instead of sticking on page URL, I've done this:

 * Implements hook_theme_suggestions_page_alter().
function mytheme_theme_suggestions_page_alter(array &$suggestions, array $variables) {

  $parameters = \Drupal::routeMatch()->getParameters()->all();
  if (isset($parameters['view_id']) && isset($parameters['display_id'])) {
    ['view_id' => $view_id, 'display_id' => $display_id] = $parameters;
    $suggestions[] = 'page__view__' . $view_id;
    $suggestions[] = 'page__view__' . $view_id . '__' . $display_id;

Then you can simply use page--view--search.html.twig


page--[url of your view].html.twig

Put the file in drupal/themes/YourTheme/templates folder

Remember to flush/clear the cache to see the changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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