Layouts

Layouts are the base of the theme, through which all templates are rendered. Use the layout file to host repeated theme elements like headers and footers.

The default layout, which all themes must contain, is theme.liquid. You can also create custom layouts. You can set templates to use custom layouts, or no layout, using the layout Liquid tag.

Layout files are hosted in the layout directory of theme.

Standard objects

There are two main Liquid objects to be included in layout files:

content_for_header

The content_for_header object outputs scripts from Shopify for things like Google Analytics, Shopify Analytics, Shopify apps, and more. You need to add a reference to this object between the <head> and </head> HTML tags.

content_for_layout

The content_for_layout object dynamically outputs the content for each template. You need to add a reference to this object between the <body> and </body> HTML tags.

Descendant selectors

You can help create CSS rules for specific templates by outputting data from the template object in the <body> tag’s class.