Section.index in the theme editor not working

Short description of issue

section.index and section.index0 not working in the theme editor

Reproduction steps

  1. Add Section index: {{ section.index0 }} to the top of a section
  2. Add the section in the theme editor
  3. Preview the section in theme editor and in theme preview

Additional info

In theme theme editor it will render Section index: and in the theme preview (storefront) it will render Section index: <index> (0 for the first section).

Is this a bug or by design?


It’s obviously mostly useful for loading related stuff, but can also be used for styling related stuff like something like a border or color for every other section. Or spacing/styling related stuff for the first section.

What type of topic is this

Bug report

Upload screenshot(s) of issue


Cool - thanks for sharing that information. That makes sense.

I actually did not really need it - I just stumpled upon it and wondered. Realised other people might as well :grin:

I think, for the sake of it, it would make sense to share it here, if you want to. It might appear in search engines :blush:

Thanks!

Dude stop with the AI answers.

As I read that again I see that’s obvious actually, lol.

Do you know if it’s correct though?

The answer is in this blog

The Online Store Editor is optimized for fast rendering by re-rendering only the section that was updated. This means that if we provided the index, it would not be consistent. Thus, both the index and index0 are forced to be nil when rendering in the Online Store Editor. These new features should be used only for non-visual reasons like optimizing loading speed for real users.

Thanks @Edward_Meehan