Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[Contentful Essentials] Managing content at scale with software code

[Contentful Essentials] Managing content at scale with software code

Contentful Webinars

February 27, 2019
Tweet

More Decks by Contentful Webinars

Other Decks in Technology

Transcript

  1. Housekeeping • This webinar is being recorded; we will share

    the recording and slide deck with all registrants • Please leave your questions in the Q&A box, we’ll answer them after the presentation • To get in touch, write to us at [email protected] before we begin...
  2. 3 1. Why “content as code” 2. Space modeling 3.

    Using Environments for CI/CD 4. 5-steps to managing your content with code 5. Refactoring using the Expand/Contract pattern 6. SDKs and tools Topics
  3. Contentful APIs allow you to manipulate content with code Content

    at scale • Independent editorial and development workflows • Continuous Integration / Continuous Deployment (CI/CD) • Refactoring content models • Large-scale content changes
  4. Independent editorial and development workflows Editorial Workflow Development Workflow Editors

    never have to pause content creation to wait for developers to make website changes Editors never have to wait for developers to deploy new or changed content Developers can run a full “code-like” change management process with version control, QA and CI/CD using the tools they are familiar with. Developers won’t get bogged down with ad hoc requests to update content
  5. Contentful Domain Model Organizations Top most parent object, connects users

    to a company. Users A User can have access to all or limited access to certain spaces based on roles & permissions. Spaces A child entity of an organization. A container for content, assets and UI extensions. Environments Are entities belonging to a space, they contain an isolated copy of content and assets.
  6. • Use spaces to separate content that has different teams

    or different use cases unless they need to share content • For large scale implementations, consider putting global shared content, team shared content and project-specific content in separate spaces • Roles are specific to a space—use separate spaces if the same users need different permissions Tips for getting the most out of spaces
  7. One space to rule them all Space 1 Used for

    microservice 1 all projects at org Project Spaces Content consists of Assemblies, Topics, and Media Best pattern for use cases where all of the following are true: • Content types and/or content entries are reusable across projects. • Projects all have the same localization needs. • Roles & Permissions provide sufficient access controls across all projects. • Content is intended to be used for multi-channel delivery. • Multiple teams or business units want to collaborate together across projects.
  8. Separate space per project Space 1 Used for microservice 1

    specific content Space 2 Used for microservice 2 specific content Space N Used for microservice N specific content ... Project Spaces Content consists of Assemblies, Topics, and Media Best pattern for use cases where one or more of the following is true: • Content types are not reusable across projects. • Projects have different localization needs. • Roles & permissions cannot be effectively used to create granular access controls. • Business units have a regulatory or legal requirement to keep their project and content separate.
  9. 3-Tier Space Pattern Space 1 Used for microservice 1 specific

    content Space 2 Used for microservice 2 specific content Space N Used for microservice N specific content ... Shared Space Used for highly reusable content across org Global Shared Spaces Project Spaces Shared Space 1 Used for reusable content for line of business 1 BU/Team Shared Spaces Shared Space K Used for reusable content for line of business K ... Content consists of Assemblies, Topics, and Media Requires UI Extension for cross space referencing
  10. Consider the following when deciding which space pattern to utilize:

    • Will governance rules (i.e. user roles and access permissions) be the same or different among the teams and projects? • Will content types be the same and/or shared across projects? • Will projects have the same localization requirements? Same or different set of locales? • Is there a legal or regulatory requirement for projects and their content to be isolated? Things to think about
  11. • Use Microservice Spaces* strategy instead of monolithic ones •

    Microservice Spaces could be defined based on: – Business Units – Business Functions – Projects – Content/Dev Teams • Goals: – Reduce dependencies and time-to-market – Improve release/publish lifecycle Space Planning Strategy
  12. FF = Future Feature • Go to Web App >

    Settings > Environments to clone Master. • Master is always considered Prod and cannot be deleted. • Merging the changes back to Master needs to be done by Contentful CLI/Scripts. (FF) • Other environments cannot be promoted to Prod. (FF) Environments Best Practices
  13. 1. Build Build your application and verify that the code

    compiles as expected. 2. Test Run automated tests; unit tests; integration tests. 3. Migrate Run your migration scripts to update your content model for the space/environment you will next deploy to. 4. Deploy Deploy the application to a number of environments. Often to a staging or pre-production environment manually test before deploying to production. 5. Test Run automated end-to-end tests against the environments you deployed your application to in the previous step. CI/CD Best Practice
  14. 1. Experiment with a content model in the web app

    where you can see JSON output 2. Create the environments you need for CI/CD. Optionally use scripts to clone the master environment. 3. Create a script to programmatically build the full content model 4. Create migration scripts to move content into and out of the content model 5. After testing, propagate your changes into the Prod environment 5 Steps
  15. Explore what content types, fields, validations etc. look like as

    JSON to speed your future script writing. Experiment with different data models. Try to add complex relationships in your model, how is that represented in JSON? 1. Create content types in the web app
  16. Every space has one master environment by default. Each environment

    is a full isolated clone of the master environment. Includes a full copy of all the content types, entries, assets, locales and webhooks. You can setup as many environments as your workflow requires. 2. Set up your initial environments
  17. Use our content-migration tool to create your content model programmatically.

    File: content-model-v1.js Write a script to execute your content model. File: create-model.js Invoke with Contentful CLI against one of the test environment. contentful space migration --space-id abcedef --environment-id feature-wow create-model.js 3. Create a script to build the content model
  18. 4. Create a migration script to update model Programmatically update

    an existing content model, i.e. migrate your content model. File: content-model-animal-v2.js Execute with same script, except use new file: contentful space migration --space-id abcedef --environment-id feature-wow create-model.js Note when you execute a content migration, both the content type and all content entries (records) based on that content type are updated!
  19. 5. Propagate your tested changes to Prod After you have

    tested and verified your changes in sandbox environment, apply the content model migration to production by simply executing the same script but specifying master as target environment. contentful space migration --space-id abcedef --environment-id master create-model.js
  20. Migrations: the “Expand” Phase Content entries such that the changes

    do not prevent the currently released version of the software from running New fields and content types By leaving the existing content in place, while augmenting the content types and content such the new version of the software can also run. The content model can now support both the current version and the new version of your software in parallel. Add Transform
  21. Migrations: the “Contract” Phase Once all users are successfully using

    your new version, the “contract” phase of the migration is to run to remove unneeded content types, fields and content. Remove
  22. Support for every Major Language SDKs in seven most popular

    programming languages for both CDA and CMA. Tools are integrations and plugins that help facilitate your application setup. ➔ Space management ◆ Contentful CLI ◆ Contentful Migration ➔ Static site generators ◆ Gatsby ◆ Metalsmith ◆ Middleman
  23. Questions Topics 1.Why “content as code” 2.Space modeling 3.5-steps to

    managing your content with code 4.Refactoring using Expand/Contract pattern 5.SDKs and tools