How to target a specific collection page on shopify

Hello, so I’m having trouble with targeting a specific collection page on my shopify website. Here’s some context:

My clients website has 3 specific pages for selling their clothing: a men’s page, women’s page, and petite page.

As part of my work (web design), I’m adding a image to the collection pages - I’m doing this by changing the background image with css.

My problem - when I change the background image on the women’s page, the background image changes on the mens and petite pages also. This is because they’re all ‘one’ (collection pages). However, I need the mens and womens pages to be different photos - the womens page with a picture of a women and the mens page with the picture of a man, etc.

Please help out if anyone knows if this can be done - find the store URL here: https://www.hclothing.com/

Hi @SamFarwell ,
body element has that unique id for both men and women collections.
for men you can add #men-39-s-clothing before your css selector.

and for women add this #women-39-s-clothing

Hi @SamFarwell ,

I understand that you need three different collection pages. The simplest way to accomplish this is by creating three collection templates and assigning them as needed. Here’s how you can do it:

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, and click Customize.
  3. Use the Template drop-down menu to select a template, then click + Create template.
  4. Give your template a unique name.
  5. Using the Template drop-down menu, select the existing template you want to base your new template on.
  6. Click Create template.

For example, you can name the new template “Men’s Collection” and design it accordingly

Repeat the process for the Petite collection. This will give you a total of three templates:

  • Default (Women)
  • Men
  • Petite

To assign the templates, follow these steps:

  1. Go to Products > Collections > Men’s Collection.
  2. In the bottom right corner, you will see a template option. Select the desired template for that collection.

I hope this helps! If you found it helpful, don’t forget to like and mark it as a solution.

Best regards,

Dawood Mirza

Use liquid inside collection template:

Variant 1.

Case collection.handle

When ‘man’

//Your css styles

Endcase

Variant 2.

Find a collection page wrapper, inside collection template.

Add there a class with liquid:

If collection.handle == ‘man’ class-name-for-man elsif … Endif

In CSS add .class-name-for-man with you color for mans collection.

There’s no option for me to create a template!

Unfortunatley this does not work.

The css applies for all collection pages. For example, if i were to add:

'h2 {

font-size: 13px;

)’

to the mens collection page, this would also show up in the css box in the womens collection page.

What theme are you using??

Brooklyn

Brooklyn version 17.3.0

Read about CSS selectors.

You need to understand selectors: id, nested element.

On the screenshot above, @Ahsan_ANC underlined a parent’s id.

So, to select any element inside body tag with id specific to the collection (see underlined id) you need to write:

#women-39-s-closing h2 {

Color: red;

}

Repeat css with that principle for all collections you need to customize.