Skip to content

Site · Data

Show database items on a page

Last updated 18 November 2026

List the items in a database on a page of your site with a GraphQL query and Liquid.

By the end of this guide, a page on your site will list the items from one of your databases. You write a GraphQL query that reads the items, and a page that shows them with Liquid.

Before you start

You need a database with some items in it, and a codebase you can deploy. If you are new to pages, read Build your first page first.

Note two names from the admin. Open the database in Data, then Databases:

  • The Database Table Path on the Configuration tab, for example modules/ins_databases/staff_members.
  • The Database Column Name of each field you want to show, for example name and email.

Write the query

Create a GraphQL file in app/graphql. Name the table by its full path. Each field value is read with property.

app/graphql/staff_members/list.graphql

query list_staff($page: Int = 1) {
  records(
    page: $page
    per_page: 20
    filter: { table: { value: "modules/ins_databases/staff_members" } }
    sort: [{ created_at: { order: DESC } }]
  ) {
    total_entries
    has_next_page
    results {
      id
      name: property(name: "name")
      email: property(name: "email")
    }
  }
}

Always give per_page. The query fails without it.

Warning

Sorting by one of your own fields orders the values as text, so 10 comes before 2. Sort by created_at, or sort the results in Liquid.

Create the page

Create a page that runs the query and loops over the results.

app/views/pages/staff.liquid

---
slug: staff
method: get
metadata:
  page_name: Staff - List
---
{% assign page_num = context.params.page | default: 1 | plus: 0 %}
{% graphql staff = 'staff_members/list', page: page_num %}

<ul>
{% for person in staff.records.results %}
  <li>{{ person.name }}: {{ person.email }}</li>
{% endfor %}
</ul>

Set page_name in the front matter. The CMS uses it to name the page in its list, and a deploy keeps it.

Deploy and check the page

Deploy both files, then open /staff on your site. You see one line for each item, newest first. Add ?page=2 to the address to see the next 20.

To show a linked item as well, such as each person's office, see Link two databases.