Skip to content
Docs
    Menu

    Content (CMS)

    References between collections

    Shows how to link items across collections, such as a post to its author, and how linked items publish together.

    A Reference field links an item to an item in another collection. A blog post can link to its author. A product can link to its category.

    Add a reference field

    1. 01

      Open the collection's schema

      In the CMS view, open the collection and click Edit Schema.

    2. 02

      Add the field

      Click Add field, name it (for example, Author) and set its type to Reference.

    3. 03

      Choose the target collections

      Open Choose target collections and tick one or more collections. To create a new one on the spot, choose New collection…, enter a Label and click Create and select. A new collection made this way starts with a title field only.

    4. 04

      Save

      Click Save changes.

    A reference field can point at more than one collection. For example, a "Featured" field could link to either a post or a product.

    Link an item

    In the item editor, click the reference field and search. Pick an item from the results to link it. To link a different item, click the current one and search again. Clear removes the link.

    If the item you want doesn't exist yet, click + New (or + Create new … at the bottom of the results). A panel opens with the other collection's fields. Fill them in and click Create and link. When a field links to several collections, choose which one to create in first.

    Linked items publish together

    A live item never links to an item that isn't live. So when you publish an item:

    • Items it links to through a required reference that aren't live yet are published with it. The publish dialog lists them under "Also published".
    • Items it links to through an optional reference that aren't live are listed with a checkbox. Tick the ones to publish too. Those you leave out show as missing on the live site.
    • If a linked item can't be published (for example, it's missing a required value), the publish is blocked until you fix it. The dialog names the item and has Open to go to it.

    The same rules apply to linked items of linked items.

    Unlinking before you unpublish or delete

    • You can't unpublish an item while live items link to it. The dialog lists them.
    • You can't delete an item while anything links to it, in a draft or a live version.

    Remove the links first. If a live item links to it, publish that item again without the link.

    Related