How to add ID to a section

Solved
bamboom
Shopify Partner
12 2 11

Does anyone know how to add an ID to a section on a homepage?

All I want to do is create an anchor link on a button to scroll down to a section, and can't believe there's no way to add an ID to a section out of the box. The limitations with Shopify design are currently driving me mad, I've been searching for hours with no luck.

Has anyone found a solution to this? I'm using the narrative theme - not that I imagine that makes any difference.

Thanks!

Accepted Solution (1)
bamboom
Shopify Partner
12 2 11

This is an accepted solution.

Never mind, sorted it.

For anyone one else looking - just add a new Custom Content section, and only have an html element in there - and add your ID in there. Makes a bit of an extra gap in your page layout, but works a charm.

View solution in original post

Replies 4 (4)
Smyth1
Visitor
1 0 0
IDs should be unique within a page, and all elements within a page should have an ID even though it is not necessary. You can add an ID to a new JavaScript Element or a pre-existing HTML Element.
 
bamboom
Shopify Partner
12 2 11

Hi, but where do you actually add the ID for an anchor link in the code? As there's no options on the section settings themselves, and I can't see where to add it from the liquid files.

bamboom
Shopify Partner
12 2 11

This is an accepted solution.

Never mind, sorted it.

For anyone one else looking - just add a new Custom Content section, and only have an html element in there - and add your ID in there. Makes a bit of an extra gap in your page layout, but works a charm.

fkshpfy
Visitor
2 0 0

Thank you for this. What an unbelievably clunky solution to an extremely common problem. Shopify disappoints again.