Skip to content
Log in

Theme templates

On this page

Theme templates are what control the content you see on your Store. They define the HTML layout as well as the data content you want to show.

The first thing you will probably want to do with your new theme is change one or more of the built-in templates. There are several kinds of template that each serve a different purpose. The ones you customize will depend on what you want to achieve.

When viewing your theme record, you’ll see a section for Theme Templates in the Related section.

Theme Templates section on the Related tab of a theme

When creating a template, there are two important pieces of data required; key and content.

The key tells the theme engine what template this is. For all page-level templates, it must start with pages/. Then for the specific page types you must specify the exact name.

For example, to customize the Home page, the key must be: pages/home

Keys must be unique for a theme, i.e. you can’t have multiple templates with the key: pages/home

Page templates

Page-level templates are templates that are output as the content of the entire page between the header and footer. They correspond to the page that the user is visiting. Some examples are, the home page, the product page, the search page, the cart page, etc.

The content specifies what will show for that template. You can supply any HTML content (including CSS and Javascript if you need, though that’s not recommended). You can also use Liquid code to create smart templates that can access your data. For more information see Liquid References.

:::note You cannot use Markdown in the templates. :::

Page Key
account pages/account
additional_payment pages/additional_payment
article pages/article
article_category pages/article_category
auth/confirmation/pending pages/auth/confirmation/pending
auth/confirmation/resend pages/auth/confirmation/resend
auth/invitation/accept pages/auth/invitation/accept
auth/invitation/pending pages/auth/invitation/pending
auth/login pages/auth/login
auth/missing_details pages/auth/missing_details
auth/password/forgot pages/auth/password/forgot
auth/password/reset pages/auth/password/reset
auth/register pages/auth/register
cart pages/cart
cart.js pages/cart.js
checkout pages/checkout
form_submission pages/form_submission
home pages/home
location pages/location
locations pages/locations
maintenance pages/maintenance
order pages/order
page pages/page
product pages/product
product_category pages/product_category
products pages/products
search pages/search
voucher pages/voucher

Alternative MIME-type rendering for pages and articles

Content pages and articles can be served in formats other than HTML. Add a supported extension to the page or article URL, and StoreConnect renders the matching format template without the store layout (no header or footer) and responds with the matching Content-Type header. Use this to build RSS feeds, JSON data endpoints, sitemaps, llms.txt files and similar structured output from StoreConnect content.

URL extension Page template Article template Content-Type served
.xml pages/page.xml pages/article.xml application/xml
.json pages/page.json pages/article.json application/json
.txt pages/page.text pages/article.text text/plain
.csv pages/page.csv pages/article.csv text/csv
.md pages/page.md pages/article.md text/markdown

These five are the only alternative formats a content page or article renders in. On a content page, any other extension, such as .png or .pdf, returns a 404 page. Note that a .txt URL renders the template with the .text suffix, not .txt.

For example, content pages are served from the store root and articles under /articles:

```

/about.md → text/markdown, layout-free body /articles/my-news-feed.xml → application/xml, layout-free body ```

How the format is chosen

For a content page, any of these selects the format:

  • URL extension. /about.md renders the page whose Path is about with the Markdown template. Extensions are not case-sensitive, so /about.MD gives the same result.
  • Query string. /about?format=md gives the same result as /about.md.
  • Accept header. A request for /about with an Accept: text/markdown header also renders the Markdown template.

Articles take the format from the URL extension or the Accept header.

A page or article whose Path already includes the extension, such as llms.txt or feed.xml, is matched first. It renders in that format at /llms.txt, and you do not need a separate page with the Path llms.

A content page that is staged in a content change but not yet published also resolves at an extension URL while you are editing. When you preview a page or article from Salesforce and the Path ends in a supported extension, the preview renders in that format rather than as HTML.

Customize the format templates

By default, each format template outputs the body of the page or article with no Markdown conversion, using current_page.plain_body_content or current_article.plain_body_content. Override the template in your theme to emit a different structure:

```liquid

{%- comment -%} pages/page.json {%- endcomment -%} {“title”: {{ current_page.title | json }}, “body”: {{ current_page.plain_body_content | json }}} ```

:::note The rendered body is the output of your Liquid template and there is no automatic XML or JSON serialization. Your template is responsible for emitting the correctly formatted markup or data structure. :::

:::note Template key uniqueness applies per format. You can have pages/cart and pages/cart.js as separate templates on the same theme, but you cannot have two templates both with the key pages/cart.js. :::

Content block templates

The second type of template you can customize are the content block templates. Content block templates are the templates used to show the various types of content blocks you use on your site. For instance, if you use a slideshow content block on your home page, it will be rendered using the built-in slideshow template. If you want to change how the slideshow looks or works, you can now customize it, or any of the other content blocks.

You can customize any of these built-in content blocks:

Content Block Key
container blocks/container
featured_articles blocks/featured_articles
featured_categories blocks/featured_categories
featured_pages blocks/featured_pages
featured_products blocks/featured_products
html blocks/html
image blocks/image
image_beside_text blocks/image_beside_text
image_text_overlay blocks/image_text_overlay
media blocks/media
slideshow blocks/slideshow
text blocks/text
video blocks/video

Custom content block templates

You can add your own custom content blocks as well. For example, if you want to create a new content block to render a widget, add an item to the Content_Block__c.Template__c picklist and give it the value widget. Then create a theme template with key blocks/widget to render your new content block.

Content block templates are created the same way as page templates. The only difference is that the key must start with blocks/ and must correspond to one of the Content Block template entries in the Content\_Block\_\_c.Template\_\_c picklist.

Snippet templates

The final template type is Snippets. Snippets are reusable templates you can load from any other template. For example, you may have a header that you want to use on each page. You can create a snippet for this as follows.

Create a new theme template with the key snippets/page_header and whatever content you want to be in your page header. Note that the key must start with snippets/ but the rest of it can be whatever you like as long as it’s unique for the theme.

New snippet theme template with key snippets/page_header and Liquid content

To use this snippet from another liquid template, use the following liquid code:

```liquid

{% render “page_header” %} ```

You’ll note that the sample snippet we created above calls a liquid variable title. The variable will be empty unless we pass a value in for it as follows:

```liquid

{% render “page_header”, title: “My Title” %} ```

Let’s update our home page template to use the header to use our new snippet.

Home page template updated to render the page_header snippet using a Liquid render tag

When we preview it we now see our new snippet is showing.

Storefront preview showing the page_header snippet rendered on the home page

You can create any number of snippets, and load them from any other template, including other snippets. However, don’t try to load a snippet into itself - you’ll cause an infinite loop and crash your site.

Was this article helpful?

Was this article helpful?