内容类型构建器
🌐 Content-type Builder
Page summary:内容类型构建器是用于设计内容类型和组件的工具。本指南概述了内容类型构建器,并涵盖字段选项、关联关系、组件使用,以及分享数据建模技巧。
在 内容类型构建器中,用户可以创建和编辑他们的内容类型,该构建器可通过管理面板的主导航访问。
概览
🌐 Overview
The 内容类型构建器允许创建和管理内容类型,这些内容类型可以是:
- 集合类型:可以管理多个条目的内容类型。
- 单一类型:只能管理一个条目的内容类型。
- 组件:可用于多种集合类型和单一类型的内容结构。尽管它们从技术上讲不是正真的内容类型,因为它们不能独立存在,但组件也是通过内容类型构建器创建和管理的,与集合类型和单一类型的方式相同。
所有三者都显示为 内容类型构建器子导航中的类别。在每个类别中列出了所有已创建的内容类型和组件。
点击 内容类型构建器子导航中的搜索图标 以查找特定的集合类型、单一类型或组件。
在内容类型构建器的子导航中,还显示了一个集中式的 保存 按钮,适用于所有内容类型和组件。随着内容类型/组件和字段状态的显示,这使你可以同时处理多个内容类型和组件。可以显示以下状态:
🌐 In the Content-type Builder's sub navigation is also displayed a centralised Save button that applies for all content-types and components. Along with the display of statuses for both content-types/components and fields, this allows you to work on several content-types and components at the same time. The following statuses can be displayed:
New或N表示某个内容类型/组件或字段是新的,尚未保存,Modified或M表示自上次保存以来内容类型/组件或字段已被修改,Deleted或D表示某个内容类型/组件或字段已被删除,但只有在保存后才会得到确认。
点击 保存 按钮旁边的 … 按钮可以访问其他选项,例如 撤销/重做上一次更改 和 放弃所有更改。这些选项也是集中化的,这意味着它们适用于自上次保存以来在所有内容类型、组件和字段上所做的最后操作。
🌐 Clicking on the ... button next to Save gives access to other options, such as Undo/Redo last change and Discard all changes. These options are also centralised, meaning that they apply to the last action(s) that was/were done on all content-types, components and fields since the last time you saved.
使用
🌐 Usage
创建内容类型
🌐 Creating content-types
内容类型构建器允许创建新的内容类型:单一类型和集合类型,也包括组件。
🌐 The Content-type Builder allows to create new content-types: single and collection types, but also components.
使用 Strapi AI 创建内容类型 NewThis content is new.
🌐 Creating content-types with Strapi AI NewThis content is new.
GrowthThis feature is available with a Growth plan.启用时,Strapi AI 会添加一个助手,帮助你使用自然语言创建或编辑内容类型。
要在内容类型构建器中使用 Strapi AI,请点击管理面板右下角的 按钮,并描述你需要的内容:

你还可以使用聊天窗口底部的 按钮,从现有的 Strapi 或前端应用导入代码,导入 Figma 项目,或附加图片以从设计中提取内容结构。
你的提示越精确,你创建的模式就越准确。
🌐 The more precise your prompts, the more accurate your created schemas are likely to be.
例如,以下提示示例在创建关系时效果很好:Could you please generate a collection of dogs then also generate an owner collection and add relationship to dogs? An owner can have multiple dogs, but a dog can only have one owner.
Strapi AI 在 Growth 计划中每月包含 1,000 个积分,并在免费试用期间提供 10 个免费积分。Strapi AI 在企业计划中不可用。
轻量级操作使用较少的积分,而更复杂的操作使用更多。
🌐 Lightweight actions use fewer credits, while more complex ones use more.
你可以在管理面板的 Settings Overview 中查看你的信用使用情况。当你的使用量达到每月配额的80%、90%和100%时,会发送通知。超额使用将产生额外费用。
积分在同一项目实例的所有用户之间共享。
🌐 Credits are shared across all users within the same project instance.
当你的积分用完时,你仍然可以继续使用 Strapi AI,超出部分将按月收费。有关 Strapi AI 的更多信息,请参阅专门的支持文章。
🌐 When your credits run out, you can keep using Strapi AI, with overages billed monthly. For more information about Strapi AI, please refer to the dedicated support article.
手动创建内容类型
🌐 Creating content-types manually

- 选择是要创建集合类型还是单一类型。
- 在 内容类型构建器的你想要创建的内容类型类别中,点击 创建新集合/单一类型。
- 在内容类型创建窗口中,在显示名称文本框中输入新内容类型的名称。
- 检查API ID以确保自动填充的值是正确的。在内容管理器中显示时,集合类型名称确实会自动变为复数形式。建议使用单数名称,但API ID字段可以用于修复任何复数化错误。
- (可选)在高级设置标签中,为新内容类型配置可用设置:
| 设置名称 | 说明 |
|---|---|
| 草稿与发布 | 勾选此复选框以允许内容类型的条目在发布之前以草稿版本进行管理(参见 草稿与发布)。 |
| 国际化 | 勾选此复选框以允许内容类型的条目被翻译为其他地区版本。 |
- 点击 继续 按钮。
- 为你的内容类型添加并配置所选字段(见 为内容类型配置字段)。
- 点击 保存 按钮。
新的内容类型只有在保存后才被视为已创建。只有在至少添加了一个字段并正确配置后,才能保存。如果未完成这些步骤,则无法创建内容类型,也无法在内容类型构建器中将其列在所属类别中,也无法在 内容管理器 中使用。
🌐 New content-types are only considered created once they have been saved. Saving is only possible if at least one field has been added and properly configured. If these steps have not been done, a content-type cannot be created, listed in its category in the Content-type Builder, and cannot be used in the Content Manager.
新组件
🌐 New component

- 在 内容类型构建器子导航的组件类别中,点击 创建新组件。
- 在组件创建窗口中,配置新组件的基本设置:
- 在显示名称文本框中输入组件名称。
- 选择一个可用类别,或在文本框中输入新类别名称来创建类别。
- (可选) 选 择一个代表新组件的图标。你可以使用搜索 来查找图标,而不是滚动浏览列表。
- 点击 继续 按钮。
- 为你的组件添加并配置所选字段(参见 为内容类型配置字段)。
- 点击 保存 按钮。
编辑内容类型
🌐 Editing content-types
内容类型构建器允许管理所有现有的内容类型。对于选定的要编辑的内容类型或组件,内容类型构建器界面的右侧显示所有可用的编辑和管理选项。
🌐 The Content-type Builder allows to manage all existing content-types. For an chosen content-type or component to edit, the right side of the Content-type Builder interface displays all available editing and management options.

设置
🌐 Settings
- 点击你的内容类型的 编辑按钮以访问其设置。
- 编辑你选择的可用设置:
- Basic settings
- Advanced settings
- 在对话框 中点击 完成 按钮。
- 在内容类型构建器导航中点击保存按钮。
字段
🌐 Fields
从列出内容类型字段的表格中,你可以:
🌐 From the table that lists the fields of your content-type, you can:
- 点击 按钮以访问字段的基本和高级设置并进行编辑
- 点击 添加另一个字段 按钮,为所选内容类型创建新字段
- 点击 按钮,然后拖放任意字段以重新排序内容类型的字段
- 点击 按钮以删除字段
编辑字段允许重命名它。然而,请记住,对于数据库来说,重命名字段意味着创建一个全新的字段并删除原来的字段。尽管数据库中的内容不会被删除,但与原字段名称相关的数据将无法再通过应用的管理面板访问。
🌐 Editing a field allows renaming it. However, keep in mind that regarding the database, renaming a field means creating a whole new field and deleting the former one. Although nothing is deleted from the database, the data that was associated with the former field name will not be accessible from the admin panel of your application anymore.
配置内容类型字段
🌐 Configuring content-types fields
内容类型由一个或多个字段组成。每个字段旨在包含特定类型的数据,这些数据在内容管理器中填写(参见 创建与编写内容)。
🌐 Content-types are composed of one or several fields. Each field is designed to contain specific kind of data, filled up in the Content Manager (see Creating & Writing content).
在 内容类型构建器中,可以在创建新的内容类型或组件时添加字段,也可以在编辑或更新内容类型或组件时添加字段。
根据创建或编辑的内容类型或组件,并非所有字段(包括组件和动态区域)始终可用。
🌐 Depending on what content-type or component is being created or edited, not all fields -including components and dynamic zones- are always available.

文本
文本字段显示一个可以包含小文本的文本框。该字段可用于标题、描述等。
🌐 The Text field displays a textbox that can contain small text. This field can be used for titles, descriptions, etc.
- Basic settings
- Advanced settings
- Condition
| 设置名称 | 说明 |
|---|---|
| 名称 | 填写文本字段的名称。 |
| 类型 | 在 短文本(最多255个字符) 和 长文本之间选择,以提供更多或更少的空间填写文本字段。 |
| 设置名称 | 说明 |
|---|---|
| 默认值 | 写入文本字段的默认值。 |
| 正则表达式模式 | 编写正则表达式以确保文本字段的值符合特定格式。 |
| 私有字段 | 选中以将字段设为私有,并防止通过 API 被找到。 |
| 启用此字段的本地化 | (如果内容类型启用了国际化)允许字段在不同语言环境下有不同的值。 |
| 必填字段 | 选中以防止在字段未填写时创建或保存条目。 |
| 唯一字段 | 选中以防止其他字段与此字段相同。 |
| 最大长度 | 选中以定义允许的最大字符数。 |
| 最小长度 | 选中以定义允许的最小字符数。 |
- 点击 应用条件 按钮。
- 根据相同内容类型的布 尔或枚举字段定义条件的 if 部分(例如,如果
boolean_field是true)。 - 通过选择隐藏或显示你正在配置的字段来定义条件的then部分(例如 then
show carousel_media)。
富文本(块)
富文本(块)字段显示一个带有实时渲染和各种选项的编辑器,用于管理富文本。此字段可用于较长的书面内容,甚至包括图片和代码。
🌐 The Rich Text (Blocks) field displays an editor with live rendering and various options to manage rich text. This field can be used for long written content, even including images and code.
- Basic settings
- Advanced settings
- Condition
| 设置名称 | 使用说明 |
|---|---|
| 名称 | 写入富文本(区块)字段的名称。 |
| 设置名称 | 说明 |
|---|---|
| 私有字段 | 勾选以将字段设为私有,并防止通过 API 被发现。 |
| 必填字段 | 勾选以防止在字段未填写时创建或保存条目。 |
| 为此字段启用本地化 |



