Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Layout templates

Describes an overview of layout templates in Optimizely Configured Commerce.

Layout Templates provide an HTML structure that wraps around the rendered header, footer and page. By default the template named "Standard.liquid" will be used. A theme may contain any number of layout templates. To render a different template the LayoutTemplate property in theme.json needs to be modified. The HTML for the current layout template will be rendered using DotLiquid and then injected into the _mainLayout.cshtml file. The _mainLayout.cshtml file has been moved out of the theme directory to clearly indicate that it is not customizable. Layout Sections are a way to inject content into _mainLayout.cshtml

DotLiquid model

The model used for layout templates contains just a few properties. It does not have access to the current page because the site is a single page application. Nothing page specific should be included in the layout.

PropertyTypeValue
BodystringThe rendered HTML for the page that is being requested
FooterstringThe rendered HTML for the footer
HeaderstringThe rendered HTML for the header
IsFooterbooleanUsed to indicate if the Footer is the current page being requested. This will generally only be true when CMS is being used to view/edit the Footer
IsHeaderbooleanUsed to indicate if the Header is the current page being requested. This will generally only be true when CMS is being used to view/edit the Header

Upgrade existing themes without layout templates

To maintain backwards compatibility for git themes - if a theme is loaded and it contains no layout templates then the layout templates from the responsive theme will be automatically loaded into it at start up. These layout templates will only exist in the database, the git theme itself is not modified.

If a git theme is then modified to include at least one layout template then those responsive layout templates will be removed from the theme at start up. This means that it is important to include the LayoutTemplate defined in your theme.json, or one named standard.liquid if your theme.json file does not contain the LayoutTemplate property.