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?
2
Answers
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.You might create a page template, for example called secondary_home.
Then, duplicate available sections for homepage (do not use the same or content will be the same), and include them in your new template.
Create a page using the template you created.
Load page in “Customize theme” then set settings for each sections.
Please note that this is only possible with statics sections as dynamic ones are only available for home.