Document toolboxDocument toolbox

Contentful Best Practices

This is a list of Contentful best practices, from content modeling workflow to Contentful App development.

 

Contentful’s Expand and Contract workflow

We can avoid breaking changes by using this method when implementing new features into the master environment of a Contentful space. Learn more via Contentful Learning Center.

TLDR; When we create new fields on a content type that may replace old ones, we do not want to remove them immediately causing some sort of break in the app we are building. Instead we should migrate the content from the old fields to the new and then disable the old fields, once changes are tested.

Migrating content from old fields to new fields with migration scripting.

We can also move content across different content types

GitHub - contentful/contentful-migration: 🚚 Migration tooling for contentful

  • Migration script example for moving content between types

const MurmurHash3 = require("imurmurhash"); module.exports = function (migration) { migration.transformEntriesToType({ // Old content type sourceContentType: "journey", // New content type targetContentType: "test", // Field we are transferring to new type from: ["journeyName", "journeyURLNickname"], // We can publish the new entries by setting this to true shouldPublish: false, // We can point to this content type on entries referencing the old type updateReferences: false, removeOldEntries: false, // This function creates a new id for the entry identityKey: function (fields) { const value = fields.journeyName["en-US"].toString(); return MurmurHash3(value).result().toString(); }, // This function takes the value from the old content type fields and // transforms them to the new transformEntryForLocale: function (fromFields, currentLocale) { return { journeyName: `copy - ${fromFields.journeyName[currentLocale]}`, journeyURL: `copy - ${fromFields.journeyURLNickname[currentLocale]}`, }; }, }); };

 

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'html-macro' is unknown.