Print search field in template file I need a search field to "pop down" under a search icon ({# Search icon #} in sample code) in my template file.

But how do i print the search block directly into a template file?

I want it to be in my menu--main--site-main-menu.html.twig 

    {% import _self as menus %}

          {#
            We call a macro which calls itself to render the full tree.
            @see http://twig.sensiolabs.org/doc/tags/macro.html
          #}
          {{ menus.menu_links(items, attributes, 0) }}

          {% macro menu_links(items, attributes, menu_level) %}
          {% import _self as menus %}

          {% if items %}

          {# List #}
          {% if menu_level == 0 %}
&lt;ul{{ attributes.addClass('layout-navigation layout-navigation layout-navigation--full-width layout--large-screen-only') }}&gt;
    {% else %}
    &lt;ul{{ attributes.addClass('layout-navigation__dropdown-menu') }}&gt;
        {% endif %}

        {% for item in items %}
            {% set item_classes = [
            item.in_active_trail ? 'active',
            ] %}

            {# List item #}
            {% if item.below and item.is_expanded %}
            &lt;li{{ item.attributes.addClass('layout-navigation__dropdown', item_classes) }}&gt;
            {% else %}
                &lt;li{{ item.attributes.addClass('layout-navigation__link', item_classes) }}&gt;
            {% endif %}

            {# Link #}
            {{ link(item.title, item.url) }}

            {# Submenu #}
            {% if item.below %}
                {{ menus.menu_links(item.below, attributes.removeClass('layout-navigation layout--large-screen-only'), menu_level + 1) }}
            {% endif %}

            &lt;/li&gt;
        {% endfor %}

        {# Search icon #}
        &lt;li class="layout-navigation__link layout-navigation__link__icon"&gt;&lt;a href="search/node"&gt;&lt;span class="icon fa fa-search"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;

    &lt;/ul&gt;
    {% endif %}

    {% endmacro %}
One way is to preprocess the menu and inject it as a variable, then print the variable:

use Drupal\block\Entity\Block;

/**
 * Implements hook_preprocess_menu().
 */
function mytheme_preprocess_menu(&amp;$variables) {
  $block = Block::load('myblock');
  $variables['myblock'] = \Drupal::entityTypeManager()-&gt;getViewBuilder('block')-&gt;view($block);
}


Then in your template:

{{ myblock }}