Create content types
A content type is a container for entries. You create one for each kind of data you want to store, such as “ブログ記事” (blog posts) or “お知らせ” (news). This page explains how to create a content type and decide the fields that become its input fields.
Before you begin
Section titled “Before you begin”- You need the [コンテンツタイプの作成とスキーマの変更](Create content types and change schemas) permission in the space. Among the built-in roles, [オーナー](Owner) and [管理者](Admin) have it
- Create a space first (“3. Create a space” in the Quickstart)
Create a content type
Section titled “Create a content type”To create a content type, do the following.
- In the admin, open the space and click [コンテンツタイプを作成](Create content type). The [+] next to [コンテンツ](Content) in the left menu opens the same screen.
- Under “どんなデータを入れますか?” (What kind of data will you store?), choose [コレクション](Collection) or [シングル](Single), then click [次へ](Next).
- In [コンテンツタイプ名](Content type name), enter a name (for example, “ブログ記事”).
- In [エンドポイント](Endpoint), enter a name using lowercase letters, digits, and hyphens (for example, “posts”), then click [次へ].
- Under “スキーマをどう始めますか?” (How do you want to start the schema?), choose how to start, then click [作成](Create).
“コンテンツタイプ「ブログ記事」を作りました” (Created content type “ブログ記事”) is shown. If you chose a starting option that has fields, the entry list screen opens. If you chose [空から作る](Start from scratch), the [スキーマ](Schema) tab opens. Next, decide the fields in “Add fields” below.
Collection and single
Section titled “Collection and single”| Format | What it holds | Examples |
|---|---|---|
| Collection | Any number of entries with the same shape | Blog posts, news, products, staff profiles |
| Single | Only 1 entry | Site settings, top page text, company profile |
You cannot change the format later.
Endpoint
Section titled “Endpoint”[エンドポイント](Endpoint) is the name that goes into the Content API URL. If [エンドポイント] is “posts”, you can get entries at https://<hostname>.hakocms.net/api/v1/content/posts.
- Lowercase letters, digits, and hyphens, up to 64 characters. It cannot start with a hyphen
- Within the same space, you cannot use the same name as another content type
- If you enter [コンテンツタイプ名](Content type name) in English letters, a suggestion is filled into [エンドポイント]. A Japanese name gives no suggestion, so enter it yourself
- You can change it later (“Change the name and endpoint” below)
How to start the schema
Section titled “How to start the schema”| Starting option | Fields created | Formats available |
|---|---|---|
| [空から作る](Start from scratch) | None. You decide them in the schema editor | Both |
| [ブログ記事](Blog post) | Title, description, eye-catch image, body | Collection |
| [お知らせ](News) | Title, date, body | Collection |
| [サイト設定](Site settings) | Site name, description, OGP image | Single |
| [JSON を読み込む](Import JSON) | As in the pasted JSON | Both |
With [JSON を読み込む](Import JSON), paste the JSON shown in [JSON で編集](Edit as JSON) in another space’s schema editor into [スキーマの JSON](Schema JSON). Use it when you want to create a content type with the same shape in another space.
Add fields
Section titled “Add fields”Fields are the input fields of an entry. Add one for each item you want to enter, such as a title or body.
To add a field, do the following.
- In the left menu, click the name of the content type.
- Click the [スキーマ](Schema) tab.
- Click [フィールドを追加](Add field).
- From the list of types, choose the type that fits the data you want to enter. The field settings panel opens on the right.
- In [表示名](Display name), enter the name shown on the input field (for example, “タイトル”).
- In [フィールド ID](Field ID), enter an ID of up to 64 characters that starts with a letter (for example, “title”). You can use letters, digits,
_, and-. - (Optional) In [説明](Description), enter a description for the people who fill in the field. It appears below the input field.
- (Optional) In [入力の決まり](Input rules), set rules such as [必須](Required).
- Click [完了](Done).
- Click [スキーマを保存](Save schema).
“保存しました” (Saved) is shown. Until you save, the number of unsaved changes appears at the top of the screen, such as “未保存の変更 1” (1 unsaved change).
[フィールド ID](Field ID) becomes the key in the Content API JSON. You cannot change it after saving. If you enter [表示名](Display name) in English letters, a suggestion is filled into [フィールド ID].
Field types
Section titled “Field types”| Type | What it holds |
|---|---|
| [テキスト](Text) | A single line of text, such as a title or name |
| [テキストエリア](Text area) | Text with line breaks, such as a description |
| [リッチエディタ](Rich editor) | Body text with headings, lists, images, and more |
| [画像](Image) | One image (thumbnail, OGP, and so on) |
| [複数画像](Multiple images) | Several images in order (a gallery, and so on) |
| [ファイル](File) | A file such as a PDF |
| [日時](Date and time) | A date and time, or a date (an event date, and so on) |
| [真偽値](Boolean) | On or off (featured post, and so on) |
| [セレクト](Select) | A choice from fixed options (category, and so on) |
| [数字](Number) | A number (price, rank, and so on) |
| [参照](Reference) | A reference to one entry of another content type (author, and so on) |
| [複数参照](Multiple references) | References to several entries of another content type (related posts, and so on) |
| [カスタム](Custom) | One custom field (a group of several fields) |
| [繰り返し](Repeater) | Any number of custom fields in a row (types can be mixed) |
The input rules you can set for each type (maximum length, options, and so on) and the shape of the values the API returns are in Field types.
Use custom fields
Section titled “Use custom fields”A custom field is a container that groups several fields. For example, you can group “見出し” (heading), “本文” (body), and “画像” (image) into one paragraph, and use a [繰り返し](Repeater) field to add as many as you like.
- Under [カスタムフィールド](Custom fields) near the bottom of the [スキーマ](Schema) tab, click [カスタムフィールドを作成](Create custom field).
- Enter [名前](Name) and [ID], then click [完了](Done).
- Click [<名前> にフィールドを追加](Add field to
) inside the custom field’s box, and add the fields to put inside. You add them the same way as steps 4–9 of “Add fields” above. - Use [フィールドを追加](Add field) to add a [カスタム](Custom) or [繰り返し](Repeater) field.
- For [カスタム], in [カスタムフィールド](Custom field); for [繰り返し], in [使えるカスタムフィールド](Allowed custom fields), choose the custom field you created in step 2.
- Click [完了], then click [スキーマを保存](Save schema).
You cannot put [カスタム] or [繰り返し] fields inside a custom field.
Change fields
Section titled “Change fields”To change a saved field, click the field’s row on the [スキーマ](Schema) tab, change the settings, click [完了](Done), and then click [スキーマを保存](Save schema).
- Reorder: Drag the handle on the left of the row. You can also select the handle and move it with the ↑ ↓ keys
- Type: You can change only between combinations that can read existing values without conversion: between [テキスト](Text) and [テキストエリア](Text area), and from [数字](Number) to [テキスト]. If you want a different type, add a new field
- Delete: Click [削除](Delete) in the settings panel. The values of a deleted field remain in the entries. Open [削除したフィールド](Deleted fields) and click [戻す](Restore) to restore the field along with its values
- Edit as JSON: Click [JSON で編集](Edit as JSON) at the top of the screen to edit the whole schema as JSON. Click [フィールド](Fields) to return to the original screen
When existing entries no longer fit
Section titled “When existing entries no longer fit”If you save a change that existing entries no longer fit, such as adding [必須](Required) or lowering the maximum length, “既存のエントリーが違反します” (Existing entries violate the schema) is shown with the number of entries that no longer fit.
- Click [適用する](Apply) to save the schema. Entry values do not change. The entries that no longer fit must be fixed the next time they are saved
- Click [キャンセル](Cancel) to not save
If you turn on [重複を許さない](Disallow duplicates) and entries with the same value already exist, you cannot save. Look at the duplicate values and entry IDs shown on the screen, fix the entries, and then save again.
If someone else saved the same schema first, “ほかの人がスキーマを更新しました” (Someone else updated the schema) is shown. Click [読み込み直す](Reload) and make the change again.
Change the name and endpoint
Section titled “Change the name and endpoint”- On the content type screen, click the [コンテンツタイプ設定](Content type settings) tab.
- Change [コンテンツタイプ名](Content type name) or [エンドポイント](Endpoint).
- Click [変更を保存](Save changes).
When you change [エンドポイント], “エンドポイントを変えますか?” (Change the endpoint?) is shown. Changing the endpoint also changes the Content API URL. Sites that use the old URL can no longer get entries. Fix the URL on the site side too, and then click [変更を保存].
Delete a content type
Section titled “Delete a content type”Deleting a content type also deletes all entries in it. This cannot be undone.
- On the content type screen, click the [コンテンツタイプ設定](Content type settings) tab.
- Under [危険な操作](Dangerous operations), click [コンテンツタイプを削除](Delete content type).
- On the confirmation screen, enter the value of the content type’s [エンドポイント](Endpoint).
- Click [コンテンツタイプを削除].
“コンテンツタイプ「ブログ記事」を削除しました” (Deleted content type “ブログ記事”) is shown.
Check that the name of the content type you created appears under [コンテンツ](Content) in the left menu. When you click the name, GET /api/v1/content/<endpoint> appears at the top of the screen. You can copy the Content API URL with the button next to it.