2
votes

I am trying to understand the shopify.

In debut theme , theme.liquid layout file i found this code {{ content_for_layout }} inside body tag.
I am sure it is loading templates and sections, but on what basis it is loading the templates or section into it.
is it written somewhere what its gonna load?
if written, please tell me the file name or explain me the rules.

1

1 Answers

4
votes

content_for_layout is the main tag that handles each template content.

This means that all of the templates in the template folder are handeled with this tag.

To make it simple content_for_layout just copy the content from the template file and add it on that spot, nothing more.

Since you need to have the same header and footer in the whole site (in most cases) the tag is added in your layout file in order to create dynamic pages ( with different content that you can edit ) with the same footer and header.

content_for_layout does not handles section the way you think. You may be confusing it with content_for_index which is indeed loading sections on the homepage, but content_for_layout just takes the content that your template file outputs and show it where the tag is called at.