No template assign to home page

Joakim2
Shopify Partner
2 0 0

Hi I'm creating a new theme for a customer. And for some reason I can't add sections to home page. There is no template assigned. If I go to collection page there is not issue at all, I can add all the sections available. If I look at my templates in Edit code there is an index.json that is an empty json object with sections and order as it should be since I can't add anything. And in my theme.liquid I use the standard {{ content_for_layout }} between main tag.  Have anyone else encountered the same issue?

Regards 

Joakim 



Screenshot 2023-02-10 at 14.29.21.pngScreenshot 2023-02-10 at 14.33.55.png

Replies 3 (3)

EcomGraduates
Shopify Partner
590 48 80

Hello there 

 

  1. In your Shopify admin panel, go to "Online Store" > "Themes" and click on "Customize" for the theme you're working on.

  2. Click on "Add section" and see if any sections are available to add to the homepage. If there are no sections available, then the issue may be related to the homepage template.

  3. Go back to the main "Themes" screen and click on "Actions" > "Edit code" for the theme you're working on.

  4. In the file list, look for a file named "templates/index.liquid". This is the template that should be assigned to the homepage. If this file is missing, then you will need to create it.

  5. Open the "index.liquid" file and add the necessary code to render the sections. The code should look something like this:

 

{% section 'featured-collection' %}
{% section 'image-with-text' %}
{% section 'product-list' %}

 

 

In this example, the code is calling three sections: "featured-collection", "image-with-text", and "product-list". Replace these with the section names that you want to include on your homepage.

  1. Save the "index.liquid" file and go back to the theme editor. You should now see the sections available to add to your homepage.

 

Sassenach22
Visitor
2 0 0

Great explanation, it helped me solve a similar problem. Thank you!

Joakim2
Shopify Partner
2 0 0

Thanks for the answer. So does this mean that index.json needs a default section like other templates, i.e. collection ({ main: main-collection})? Index doesn't seem have that, only sections and order. And other sections  should get a generated ID. I get that you can remove the "hard-coded" section afterwards. But I would like to know what the best practice is.