How to get section id within the same pag

How to get section id within the same pag

Alexweee
Shopify Partner
1 0 1

I have 2 sections that are included on the same page, and in section 1, I have a button that I want to set the href to #section_2.

 

It works if I manually paste the dynamically generated section id of section 2 as href, but it seems that shopify would dynamically generate this id and it might change (not sure when it would regenerate), which will break this functionality.

 

Therefore, I am looking for a way to get the dynamically generated section id programmatically and pass that as the href to avoid potential breakage.

 

Thanks

Reply 1 (1)

Dan-From-Ryviu
Shopify Partner
11633 2279 2462

Hi @Alexweee 

Shopify automatically generates an ID each time you create a new section. But you can customize the liquid code of the section and wrap all the code of into your dynamically ID 

<div id="your-dynamically-id">
// code of your section' file
</div>

 

- Helpful? Like & Accept solution!
- Ryviu - Product Reviews & QA app: Collect customer reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Dhgate and CSV.
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...
Sign up now.