Content

Content Versioning

This guide covers the process of enabling and utilizing Content Versioning in Directus.

Content versioning allows teams to create and manage different versions of their content. There are several reasons to use content versioning, including drafting content without publishing it, and more ways to collaborate effectively.

Concepts

  • Version: A version of an item is a snapshot that gets copied from the current or main version, allowing you to safely make changes and later promote to be the main version. Any changes to the main version made in the meantime are updated automatically.
  • Main: the main version is the original version of a piece of content that has been created. It is the default version that is displayed to users. The main version is the "source of truth" for all other versions. This is often used for published content.
  • Promote: promoting a version means to make it the new main version. When a new version is promoted, it becomes the main version that is displayed to users, and it replaces the previous main version.
Using Versions in Live Preview
The version field is a dynamic variable can be added to the live preview URL so you can preview a specific version of an item. Check out more about live previews.

Setting Up Content Versioning

Content versioning checkbox

Navigate to Settings > Data Model, select the collection that you want to enable content versioning for, and scroll down to the content versioning section. Toggle "Enable Versions" and save your data model.

Creating a New Version

Creating a new version in the content module -->

Open an item within your versioned collection. At the top of the item view, you will notice a dropdown with the main Content Version displayed as "main". Select "Create Version" and provide a key and a name for the new version. You can then save your new version.

Version Source
All new versions originate from the main version. This implies that the main version acts as the single source of truth for other versions.

Making Changes to a Version

Editing a version

Open the item in the newly created version, and make the desired edits to the item's content.

Upon saving the changes, you'll notice that the main version remains unaffected, while the changes are reflected only in the modified version.

Reviewing and Promoting a Version

Promoting a version, comparing its changes

Promoting a version will turn it into the main version.

Open the version you want to promote and select the "Promote Version" option from the dropdown. In the "Changes" tab, you can review the changes made for each field in the version and decide which field's changes to accept or reject. Switch to the "Preview" tab to see a preview of the changes you are about to promote.

After promoting a version, you can choose to keep or delete the version.

Programmatically Implement Content Versioning
You have the option to integrate Content Versioning through the API. To learn how to accomplish this, please refer to our API reference documentation.

Revisions and Content Versioning

Under the hood, content versions are stored in the directus_revisions collection. In bigger projects this collection can get large.

This can be mitigated by periodically removing some or all data in this collection. Note that this could unintentionally remove some content versions.