How do I link two collections?
Learn how to connect two collections in Blutui so you can reuse shared content without duplicating data.
Introduction
Now that you know how to create collections, you may want to link one collection to another.
This allows you to reuse existing content instead of duplicating it across multiple collections.
In this guide, we’ll walk through linking a Locations collection to a Staff collection.
This will allow each staff entry to reference a location dynamically based on entries in the Locations collection — all managed through the dashboard.
Create and prepare your collections
For this example, you should have:
- A Locations collection (e.g., Auckland, Wellington, Christchurch)
- A Staff collection
If you haven't created these yet, do that first.
Add a link field in your collection settings
Blutui allows you to link collections directly from the dashboard — no code required.
- Open the Locations collection in your project dashboard.
- Click Manage links.
- Click New link.
- Select the field you want to link (e.g., a
locationreference). - Give your link a Name — just like naming a field type.
This creates a relationship between collections so you can easily reference entries from one collection inside another.
Access linked collection values in Canvas
Once a link has been created, you can access it from your Canvas templates in two ways:
Option A — Access via foreign_keys
{{ entry.foreign_keys.location }}This is the canonical way to retrieve linked collection values.
Option B — Access directly from the entry object (shortcut)
{{ entry.location }}Note: This shortcut only works if your entry does not already have a
locationfield defined. If you already have a field calledlocation, always use theforeign_keysversion.
Example Use Case
If your Staff collection has a linked location, you can display it like this:
<div class="staff-member">
<h2>{{ entry.name }}</h2>
<p>Based in: {{ entry.location.name }}</p>
</div>Or using the full foreign key reference:
<p>Based in: {{ entry.foreign_keys.location.name }}</p>This allows you to update and manage locations in one place — the Locations collection — while automatically updating all linked Staff entries.
Why link collections?
Linking collections helps you:
- Avoid duplicated data
- Maintain consistency across related content
- Scale content without rewriting it
- Manage shared data (like locations, categories, authors, services, products, etc.) in one place
It’s one of the most powerful features for building flexible, data-driven sites in Blutui.
Next steps
You can now try linking more collections — such as categories, tags, teams, or related products — and build powerful relational content structures.
Last updated on
How do I expand page content using collection data?
Learn how to use collections to extend and enrich your page content — for example, adding author details to blog posts.
How do I use route patterns in my project?
Learn how to use route patterns in Blutui to dynamically generate pages from collections, such as individual team member profiles.