Warning
You're browsing the documentation for an old version of Webiny. Consider upgrading your project to Webiny 5.40.x.
What you will learn
  • best practices for content modeling
  • create scalable, reusable, and efficient content structures
  • content modeling in Webiny

Content Modeling Best Practices
anchor

Creating a well-structured content model is vital for leveraging the complete capabilities of a headless CMS like Webiny. By structuring your content properly, you can ensure scalability, reusability, and ease of management. This guide provides best practices for defining content types, designing for reusability, planning for scalability, and optimizing for simplicity. Whether you’re starting fresh or refining your existing setup, these strategies will help you build a robust and adaptable content model that meets your business needs.

Identify and Define Content Types
anchor

Comprehensive Content Assessment
anchor

Begin by thoroughly analyzing the various types of content your organization needs. This encompasses primary content such as blog posts, product details, and user profiles, as well as auxiliary content like metadata, categories, and tags.

Attribute Specification
anchor

Once you identify the content, the next step is to clearly define the attributes for each content type. For example, a blog post may contain attributes such as title, slug, featured image, tags, category, and body. Each attribute can be of a different type. Webiny supports a wide range of attribute types; you can find more details here.

Design for Reusability
anchor

Component-Based Design & Establishing Content Relationships
anchor

Decompose your content into modular, reusable components. Instead of embedding categories directly within each blog post, create a separate category content type. This allows you to reference these categories across multiple blog posts, ensuring consistency and simplifying updates. In Webiny, you can use the Reference field to define relationships between different content types.

Plan for Scalability
anchor

Adaptable Models
anchor

Create content models that can easily adapt to growing needs. Ensure that adding new fields or content types does not require extensive restructuring. This flexibility allows your CMS to evolve alongside your business.

Content and Presentation Separation
anchor

Structure your content independently of its presentation. This ensures that the same content can be delivered across multiple platforms (web, mobile, etc.) without modification.

Optimize for Simplicity and Uniformity
anchor

Intuitive Naming Conventions
anchor

Implement clear and intuitive naming conventions for content types and fields to improve usability and maintain consistency.

Standardized Templates
anchor

Develop standard templates for frequently used content types to streamline content creation and maintain uniformity. In Webiny, you can use the Dynamic Zone field to define templates for your content and validation rules for those templates.

Consider Localization and Internationalization
anchor

Multilingual Support
anchor

Design your data models to support multiple languages if your content will be available in different languages. Webiny offers content localization that allows you to adapt your content to different languages by creating multiple locales. You can learn more about content localization in Webiny here.

Develop a Multi-Channel Content Strategy
anchor

Channel-Agnostic Content
anchor

As mentioned earlier in the Plan for Scalability section, you should design your content model to be easily adaptable for various platforms, including websites, mobile apps, and social media.

Metadata Inclusion
anchor

Incorporate metadata fields in your content model, such as SEO titles, descriptions, and keywords, to enhance search engine optimization and content discoverability.

Adopt a Collaborative and Iterative Approach
anchor

Cross-Functional Collaboration
anchor

Involve stakeholders from different departments, such as design, development, and marketing, in the content modeling process to ensure the model meets diverse requirements and is user-friendly.

Continuous Improvement
anchor

Regularly review and update your content models based on user feedback and changing business needs to maintain an efficient content structure.

Documentation
anchor

Maintain comprehensive documentation for your content models, including definitions for each content type, attributes, and relationships. This serves as a reference for your team and aids in onboarding new members. By adhering to these best practices, you can build a versatile and scalable content model in Webiny Headless CMS, ensuring that your content remains well-structured, manageable, and adaptable to future needs.

Content Modeling in Webiny
anchor

Webiny supports a wide range of content model field types that allow you to create a well-structured content model efficiently. Here are the field types supported in Webiny:

  • Input
    • A single-line text input or a multi-entry input
    • Can also be a list of predefined values the user can select
  • Number
    • An integer or a float
  • Text
    • Multi-line text
    • Doesn’t support text formatting
  • Rich text
    • A multi-line rich text field that supports text formatting and inline images
  • Boolean
    • True or false toggle
  • File
    • Used for inserting a single file, multiple files, a single image or an image gallery
  • Reference
    • References another content model
    • Supports both single entries and multiple select
  • Object
    • Nested object field
    • Inside this field, you can place multiple other fields such as text, file, and others
    • You can nest objects to as many depth levels as you need
  • Dynamic zone
    • A Dynamic Zone is a field that can contain multiple other fields
    • The difference between a dynamic zone and an object is that a dynamic zone allows you to select which fields you want to use
    • This is useful when you have a content model that has a lot of fields, but you only want to use a few of them in a particular entry
    • You can also nest dynamic zones to as many depth levels as you need
    • See the Dynamic Zone in action: https://www.youtube.com/watch?v=8Z3Z3Y5Q5Zoexternal link

Besides the default built-in attributes, you can expand Webiny with custom plugins that introduce new fields.

Searching With Reference Field and Objects - Considerations
anchor

Using Reference Fields, you can only search using the ID or entry ID. For example, let’s say you have two models, Article and Category. Article model has a reference field Category, which refers to the Category model. If you want to find all articles associated with a category named abc in the Article model, you will first need to fetch the ID of the abc category from the Category model. Then, you can query using this category ID or entry ID in the Article model to retrieve the articles belonging to this category.

Using Objects allows you to search and filter through the data because they are part of the entry itself, but they cannot be used as independent entities in other models.

When selecting your tools, e.g., Objects vs. Reference fields, it is important to be crystal clear on your use case. If in doubt please reach out to the team on community Slackexternal link with the specific requirement or user story.

Dynamic Zone
anchor

As mentioned earlier, the Dynamic Zone field allows you to define templates for your content and validation rules for those templates. Then, while creating your content, you can decide which template you want to use from the predefined set of templates. This way you can define structure for your content writers, and have them use prebuilt content types. Please note that when querying content data, you cannot filter content based on the Dynamic Zone field in the model.

You can learn more about Dynamic Zone here: https://www.youtube.com/watch?v=4hOScz42_Nwexternal link