How to get the recommended product on the blog page from the same tag in Shopify?

Today in this blog, We will see how to get the recommended product on the blog page from the same tag.

Get all the products of the collection first to get recommended products. Then compare the product and blog tag and then get the product image, product title, and price.

For Example:

<div class="recommend -product">
	<div class="container">
		<div class="row">
		{% for product in collections.all.products %}
			{% capture my_variable %}{{blog.tags}}{% endcapture %}
				{% if product.tags contains my_variable  %}
				<div class="recommend -product-info">
					<a href="{{product.url}}"><img src="{{ product | img_url: "medium" }}" /></a>
					<h1>{{product.title}}</h1>
					<span>{{product.price}}</span>  
				</div>
				{% endif %}
		{% endfor %}
		</div>
	</div>
</div>

Hope this blog is helpful for you, Thanks for reading this blog.