search bar for blog only

I found this code from a youtube tutorial. I added it to the section custom liquid. I would like this search bar to only search the blog.

{{ ‘template-collection.css’ | asset_url | stylesheet_tag }}
{{ ‘component-card.css’ | asset_url | stylesheet_tag }}
{{ ‘component-price.css’ | asset_url | stylesheet_tag }}
{{ ‘component-search.css’ | asset_url | stylesheet_tag }}

{%- if section.settings.enable_filtering or section.settings.enable_sorting -%}
{{ ‘component-facets.css’ | asset_url | stylesheet_tag }}

{%- endif -%}

.template-search__header { margin-bottom: 3rem; } .template-search__search { margin: 0 auto 3.5rem; max-width: 74.1rem; } .template-search__search .search { margin-top: 3rem; } .template-search--empty { padding-bottom: 18rem; } @media screen and (min-width: 750px) { .template-search__header { margin-bottom: 5rem; } } .search__button .icon { height: 1.8rem; }

{%- liquid
assign sort_by = search.sort_by | default: search.default_sort_by
assign terms = search.terms | escape
assign search_url = ‘?q=’ | append: terms | append: ‘&options%5Bprefix%5D=last&sort_by=’ | append: sort_by
-%}

{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}

@media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
{%- endstyle -%}

{%- if search.performed -%} {{- 'templates.search.title' | t -}} {%- else -%} {{- 'general.search.search' | t -}} {%- endif -%}

{%- if settings.predictive_search_enabled -%} {%- endif -%}
{{ 'general.search.search' | t }}

{%- if settings.predictive_search_enabled -%}


{%- endif -%}

{%- if settings.predictive_search_enabled -%} {%- endif -%}
{%- if search.performed -%} {%- unless section.settings.enable_filtering or section.settings.enable_sorting -%} {%- if search.results_count > 0 -%}

{{ 'templates.search.results_with_count_and_term' | t: terms: search.terms, count: search.results_count }}

{%- endif -%} {%- endunless -%} {%- if search.results_count == 0 and search.filters == empty -%}

{{ 'templates.search.no_results' | t: terms: search.terms }}

{%- endif -%} {%- endif -%}
{%- if search.performed -%} {%- if section.settings.enable_sorting and section.settings.filter_type == 'vertical' and search.filters != empty -%}

{{ 'products.facets.sort_by_label' | t }}

{%- assign sort_by = search.sort_by | default: search.default_sort_by -%} {% render 'icon-caret' %}
{{ 'products.facets.sort_button' | t }}

{%- if search.results_count -%} {{ 'templates.search.results_with_count' | t: terms: search.terms, count: search.results_count }} {%- elsif search.products_count == search.all_products_count -%} {{ 'products.facets.product_count_simple' | t: count: search.products_count }} {%- else -%} {{ 'products.facets.product_count' | t: product_count: search.products_count, count: search.all_products_count }} {%- endif -%}

{%- endif -%} {%- if search.filters != empty -%} {%- if section.settings.enable_filtering or section.settings.enable_sorting -%} {%- endif -%} {%- endif -%}
{%- if search.results.size == 0 and search.filters != empty -%}

{{ 'sections.collection_template.empty' | t }}
{{ 'sections.collection_template.use_fewer_filters_html' | t: link: search_url, class: "underlined-link link" }}

{%- else -%}
    {%- for item in search.results -%} {% assign lazy_load = false %} {%- if forloop.index > 2 -%} {%- assign lazy_load = true -%} {%- endif -%}
  • {%- case item.object_type -%} {%- when 'product' -%} {%- capture product_settings -%}{%- if section.settings.product_show_vendor -%}vendor,{%- endif -%}title,price{%- endcapture -%} {% render 'card-product', card_product: item, media_aspect_ratio: section.settings.image_ratio, show_secondary_image: section.settings.show_secondary_image, show_vendor: section.settings.show_vendor, show_rating: section.settings.show_rating, lazy_load: lazy_load %} {%- when 'article' -%} {% render 'article-card', article: item, show_image: true, show_date: section.settings.article_show_date, show_author: section.settings.article_show_author, show_badge: true, media_aspect_ratio: 1, lazy_load: lazy_load %} {%- when 'page' -%}
    {{ 'templates.search.page' | t }}
    {%- endcase -%}
  • {%- endfor -%}
{%- endif -%}
{%- endif -%}

You can have your search display blog articles only by adding a hidden input to your search form. You’ll need to identify where the form occurs in your code and add a couple of hidden inputs, where the input with the name attribute is “type” with a value set to “article”, additionally you can add another hidden input for a specific blog if you only want to display results from a certain blog:


See this thread as well:

https://community.shopify.com/post/831446