How-to guides

The examples come from Four Mile Books, the test store we run the app against: a classics imprint with Book (title, author, series, series order, genres, first published, pages, blurb, featured, added on, product, cover), Author (name, born, died, nationality, biography), Series, Genre, Event (title, date, book), Reading list (name, books, collections) and Staff pick (staff name, month, book). Replace the fields with your own; the shape of each list is what carries over.

The simplest list: entries with a flag set, capped at eight.

  1. Create a list called Featured books. Source: Book.
  2. Condition: Featured · is · true.
  3. Sort: Title · ascending. Limit: 8.
  4. Save. The list is written to shop.metafields.lists.featured-books.

Paste the snippet from the editor into your home-page section. Store-wide lists can also be bound as a dynamic source on any section that offers a metaobject list setting.

Screenshot: the Featured books list in the editor, with the preview showing eight titles

New this month, without editing anything

Date fields have relative operators that are evaluated when the list is refreshed, so the list moves on by itself.

  1. Source: Book. Condition: Added on · in the last · 30 days.
  2. Sort: Added on · descending. Limit: 12.

The nightly sweep re-evaluates every list, so a book that falls outside the window drops out the following night even if nothing else changed. Related operators: in the next N days, is in the past, is in the future.

Events in the next 30 days

The same idea on a different type. Source: Event. Condition: Date · in the next · 30 days. Sort: Date · ascending. Each event references a book, so the snippet can link through to the product: entry.book.value.product.value.url.

Books by this author, on the author's page

An author page wants every book that references that author.

  1. Create a list called Books by this author. Source: Book.
  2. Under Where it shows choose Per referenced entry and pick the reference field, Author.
  3. Sort: First published · ascending.
  4. Save. The app writes one JSON metafield, lists.books-by-author, keyed by author handle, up to 20 books each.

On the author's metaobject page, which Shopify serves at /pages/authors/jane-austen once the type has web pages enabled, the snippet looks the map up with the author's handle and loads each book. The same shape gives Books in this series on a series page, sorted by Series order, and Events for this book on a book page.

The rest of the series, on a product page

The reverse view: on the product page for one book, the other books in its series.

  1. Create a list called In this series. Source: Book.
  2. Under Where it shows choose Per entry and pick the shared field, Series.
  3. Sort: Series order · ascending.
  4. Save. The app writes one JSON metafield, lists.in-this-series, keyed by book handle.

A product page needs to know its book. Four Mile Books stores a product metafield, custom.book, that references the Book entry; the snippet reads product.metafields.custom.book.value.system.handle and looks the map up with it. More by this author is the same list with Author as the shared field.

Screenshot: The Hound of the Baskervilles product page showing the seven other Sherlock Holmes books in reading order

Reading lists that include this book

Per-product lists are for entries that reference products directly.

  1. Create a list called Reading lists featuring this book. Source: Reading list.
  2. Under Where it shows choose Per product and pick the field that references products, Books.
  3. Save. Each product that appears on at least one reading list gets a lists.reading-lists-for-book metafield holding those lists.

In the theme editor, open a product template, add a block that accepts a metaobject list, open the dynamic source picker and choose the metafield. Or read product.metafields.lists.reading-lists-for-book.value in Liquid. Products on no reading list have no metafield, so a bound block renders nothing.

Per collection works the same way through a field that references collections: reading lists carry a Collections field, so the detective collection shows the reading lists filed under it.

Through a relationship: books by French authors

A condition can look at the entry a reference points at. In the field menu, reference fields expand to show the fields of the type they reference, written Author › Nationality.

  1. Source: Book. Condition: Author › Nationality · is · French.
  2. Sort: Title · ascending.

The app follows the reference and tests the nationality on the author entry. This works for single and list references, one level deep. For a list reference such as Genres › Name contains "gothic", the condition is true if any referenced genre matches.

Detective or gothic, British, under 300 pages

Groups let you mix all-of and any-of, and this is the list on the Four Mile Books home page.

  1. Source: Book. Condition: Author › Nationality · is · British.
  2. Choose Add group, set it to any of, and inside it add Genres · includes · Detective and mystery and Genres · includes · Horror and gothic.
  3. Back at the top level add Pages · is less than · 300.
  4. Sort: First published · descending. Limit: 12.

The top-level group is all of, so the result is British books that are detective or gothic and short. Groups nest as deep as you need.

Screenshot: the conditions panel with a relationship condition, an any-of group of two genre conditions, and a number condition

A hero and the rest

To show the newest arrival large and the next eight small, make two lists on the same conditions:

  • Latest arrival: sort Added on descending, limit 1.
  • More arrivals: the same sort, offset 1, limit 8.

Both are refreshed together when an entry changes, so they never overlap. The offset applies after sorting and before the limit. The same trick gives storefront pages longer than 50: All books 1 with a limit of 50, All books 2 with an offset of 50, and so on, because Liquid shows only the first 50 entries of any one list.

Entries missing something

is empty and is not empty work on every field, including references and lists. A maintenance list such as Books with no page count (Pages · is empty) is worth keeping for the content team even if the theme never reads it.

Include drafts

Lists exclude draft entries by default. Tick Include drafts under Order and size for a preview list on a development store. Remember to untick it before export.