Creating A Secondary Index Page With Identical Sections As Primary Index Page But Different Content?

- 1 answer

I'm attempting to create a secondary index page for a theme that I'm working on. It would have the same sections as the primary index page, but with different content. I don't mind hardcoding this instead of it being editable from theme editor.

I've created a new index template called secondary, and copied the code from index.liquid into it. Everything shows up fine.

Then I tried to create a new block in the settings_data.json, right under content_for_index called content_for_secondary, but trying to call it in my new page template isn't working.

I've looked all over for documentation but I can't seem to find exactly how Shopify is handling sections in the settings_data.json and how I can create a new array of sections to call in an alternate template.

Has anyone had any experience with this?



You can't change {{ content_for_index }} it's a global variable. You can read more about it here.

Therefore {{ content_for_secondary }} isn't actually anything, this is why nothing is rendered.

Depending on what you are trying to achieve I think you are best off creating the index sections as statically included sections using {% section 'foobar' %} This way the content on the homepage will still be largely editable. You won't however be able to adjust their order in the theme settings. Check out the link above it will tell you all you need to know.