How do I render search block form in theme template? I've customized the search block in &quot;block--search-form-block.html.twig&quot; and it works using block layout on Drupal 9. Is it possible to render the Search Block directly in page.html.twig?
I've tried this and it giving me error (The website encountered an unexpected error. Please try again later.).
Here are the 3 methods I found.
1 - Use plugin.manger.block to render search_form_block
-- in mytheme.theme
function MYTHEME_preprocess_page(&amp;$variables) {
  $customblock = \Drupal::service('plugin.manager.block')-&gt;createInstance('search_form_block', []);
  $variables['content']['custom_block_output'] = $customblock-&gt;build();
}

-- in page.html.twig
{{ content.custom_block_output }}

2 - Same as 1 but render a customized search block from block--search-form-block.html.twig.
-- in mytheme.theme - Same as method 1
-- in page.html.twig
{% include '@MYTHEME/block--search-form-block.html.twig' %}

3 - Use Twig Tweak - credit to No Sssweat's Post

install the Twig Tweak module
insert {{ drupal_block(search_form_block') }} on page.html.twig