Reference List

On this page:

First, JSON Template is not JSON

Second, if you have no idea what JSON is or what it looks like, check out this page.

Sections & Repeated Sections

Sections do most of the work in JSON Template. There are two important things you need to know about sections and repeated sections:

  1. The content inside a section will only display if the section exists
  2. Sections define scope, meaning they set the root for any data tags added inside them (more detail).


{.section item} If this section exists, display this {.end}

Repeated Sections

{.repeated section items}
  If there are any items, repeat this info for each item

Alternating Sections

{.repeated section items}
  This stuff shows for each item.
{.alternates with}
  ------ *show this dashed line in between each item*

Or statements

Can be used within sections and repeated sections. Used to display something if the condition of the section/repeated section is not met...e.g. if the section does not exist:

{.section item}
  Item exists!
  Item does not exist :(

Data Tags

Used to inject data from the JSON into your file.

The following example will inject the title data (in this case a string of text):


You can also dig down into the JSON structure using dot notation:


Index reference (@)

The '@' carries a reference to the item you are scoped within - same as 'this' in JavaScript. This is commonly used for displaying an html tag only if the item exists.

Take the following statement:

<div class="title">{title}</div>

If {title} did not exist, the div structure would still be written to the html as an empty div:

<div class="title"></div>

To prevent this, the statement can be written like this:

{.section title}<div>{@}</div>{.end}

This way, if there is no title, nothing is written to the html.

Thumbnail Images

Many collection post types have an associated main image. These images are tied to the post via the post url, so you need to access it in kind of a funny way:


Every thumbnail image is available in multiple widths:

original, 1500w, 1000w, 750w, 500w, 300w, 100w

There is also a special test for whether a post has a main image specified, so that you will not end up with an empty <img> tag if there is no main image uploaded for a particular post:


Example use:

{.main-image?}<img src="{fullUrl}?format=750w" />{.end}

If your template relies on a main image to maintain the style of your post display, you can create a fall-back by using the {.or} statement:

  <img src="{fullUrl}?format=750w" />
  <img src="[fallback-img-URL]" />


Adds an "s" to the word if the value is > 1

You have {num} message{num|pluralize}.

Adds "es" to the word if the value is > 1

They suffered {num} loss{num|pluralize es}.

Facilitates subject-verb agreement

There {num|pluralize is are} {num} song{num|pluralize}.

Custom Pluralizer (first value assigned if 1, second if > 1)

{num-people|pluralize/It depends/They depend} on {num-things} thing{num-things|pluralize}.

Advanced pluralization

{.repeated section num}

    There are {@} people here.
  {.or singular?}
    There is one person here.
    There is nobody here.



Date/Time Formatters

Format a date in line with YUI date formatting syntax:

{addedOn|date %A, %B %d}

Timesince Date formatting (twitter-style):


String Formatters

html – Escapes html tags (<, >, &)


htmltag – Escapes html tags and quotes (<, >, &, ")


slugify – Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens.


smartypants – translates plain ASCII punctuation characters into “smart” typographic punctuation HTML entities (source:



These are a series of Squarespace-specific additions to JSON Template... they are a list of tests to limit code to specific situations.

All predicates work like this:

  code if the predicate test returns true
  code if it the test is not true

Commonly Used Predicates

Does this item (or collection) have a thumbnail image set?


Does this item have an excerpt set?


Are comments on for this item?


Are Disqus comments enabled for this item?


Promoted Block Predicates

Does this item have a particular block type promoted?


Available [blockName] tests (replace [blockName] above with one of these types):

map, embed, image, code, quote, twitter, link, video, foursquare, instagram, form

Navigation Template Predicates

Is this navigation item an external link?


Is this navigation item a folder?


Other Predicates

Does this item have location data?


Is this item an event post type?