How can I add a featured image from a blog post to my homepage on shopify
here is my code so far:
{% for article in blogs["field-notes"].articles limit: 2 %}
<li>{{ article.title | link_to: article.url }}</li>
{% endfor %}
What I want to do is have the blog post featured image as the background of the li
Answer
You get the featured image using article.image or article.image.src, and you can also use the img_url filter to get the appropriate size of that image.
{% for article in blogs["field-notes"].articles %}
<li style="background-image:url({{ article.image.src | img_url: 'medium' }});">
<a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="{{ article.url }}">{{ article.title }}</a>
</li>
{% endfor %}
source: stackoverflow.com