Shopify – Assign Featured Image to Pages

Overview

Featured images allow for better customization if you have to build unique custom header images for specific posts and pages or set thumbnails for special features of your theme.

Shopify lets you add featured images for products and collections.
But unlike WordPress, there is no option of adding featured images to pages in Shopify!

Now, what if we want different images for different pages?

While customizing the theme, you may require to have such functionality to assign featured images to pages.

shopify-featured-image-image3

Best way to get it done takes a little modification in template file code!
Do not worry if you don’t know about development. Just follow the given steps:

Step – 1 Upload image to the dashboard

Add a new image you want to assign to the page. Remember you have to upload the image of the same name as page handle.
For example, If I want to assign an image to About us page that has URL “https://abc.myshopify.com/pages/about-us”, I will upload an image named “about-us.jpeg”

Note: Here you can upload an image of any extension but remember to keep each image with the same extension as we are using it dynamically.

Step – 2 Modify theme file for adding featured image to single page

Place below code in theme.liquid file

Above snippet checks, if the current page is of page template and is “About us” page then will display the image you have uploaded for the page.

That’s it! We’re done for the single page!

Step – 3 Modify theme file for adding featured image to all pages

Now I have uploaded images for each page and want to assign each page a different image!
shopify-featured-image-image1

No worries you can do it for any number of pages!
Change 1st line of above code with following:

Horray… You created the featured image for each page!

shopify-featured-image-image2

mm

Hiteshi Trivedi Web Developer

I am working as a Web Developer at Yudiz Solutions Pvt. Ltd. - a leading mobile app, mobile games & software development company. I like to play merging of WordPress with other frameworks like laravel and Codeigniter. I customize many WP Plugins and Themes including WooCommerce.

Comments are closed.

Top