Template Docs Commerce APIs Webhooks Tools
Get Started
Get Started

Custom Query Tag

A query allows you to display items from any collection on any page of your site. A Squarespace Query can be filtered by several parameters.

Important: the contents of a <squarespace:query> is not cached and may increase page load time. There is a hard limit of eight queries per page and 100 results per query.

Querying Items

To initiate a Squarespace Query, add the query tag to your collection page with one more parameters. All parameters are optional except for collection. All code inside of the opening and closing query tags will inherit the scope set by the parameters.

<squarespace:query collection="new-blog" limit="10">

  <ol>
    {.repeated section items}
      <li><a href="{fullUrl}">{title}</a></li>
    {.end}
  </ol>

</squarespace:query>

Parameters

  • collection="" The collection URL ID (slug) to query (required)
  • limit="" The number of items you'd like returned (number, max 100)
  • skip="" The number of returned items you'd like to skip (number, max 10)
  • category="" Only return items that have this category (comma delimited)
  • tag="" Only return items that have this tag (comma delimited)
  • featured="" Filters the return to show only Featured posts. (boolean)

Example

This example demonstrates how to create a featured item module that is flexible enough to be used on any .list file. To achieve that flexibility we'll pull in the collection URL dynamically.

blog.list
----------------------------

<squarespace:query collection="{.section collection}{urlId}{.end}" featured="true" limit="5">

  <div class="featured-wrapper">
    {.repeated section items}
    <div class="featured-post">
      {.main-image?}<img {@|image-meta} />{.end}
      <h2>{title}</h2>
    </div>
    {.end}
  </div>

</squarespace:query>