Skip to main content
HydroGo
Content typesContent types

Content types

Model anything beyond pages and news with one YAML file. HydroGo derives storage, validation, admin screens and a public API from it.

Anything that is not a page, a news article or a member is a content type: one YAML file in content-types/. No Go and no Svelte are involved. From the file HydroGo derives:

  • database storage and validation,
  • admin screens at /admin/content/<id> (list, search, filters, edit form, drafts, revisions),
  • with public: true, a read API at /api/v1/content/<id> (see Content API).

A complete example

content-types/recipes.yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/hydrohq/hydrogo/main/docs/schemas/content-type.schema.json
id: recipes
label: Recipes
description: Dishes shown on the food blog.
title_field: title
public: true      # serve published records at /api/v1/content/recipes
drafts: true      # records start as drafts; the public API returns only published ones
revisions: true   # keep the last 50 versions, with compare and restore
fields:
  - {id: title,  label: Title,  kind: text,     required: true, list: true, searchable: true}
  - {id: course, label: Course, kind: select,   options: [starter, main, dessert], list: true, filterable: true}
  - {id: photo,  label: Photo,  kind: media}
  - {id: author, label: Author, kind: relation, to: team}
  - {id: method, label: Method, kind: richtext, searchable: true}

Restart hydro serve after adding or changing a file. Unknown YAML keys are rejected, so a typo fails loudly instead of being ignored.

Type keys

KeyRequiredMeaning
idyesLowercase letters, digits and underscores, starting with a letter (max 63 characters). Becomes the URL segment in /api/v1/content/<id> and /admin/content/<id>.
labelyesHuman name shown in the admin.
fieldsyesAt least one field. See Fields.
descriptionnoHelp text under the title in the admin.
groupnoAdmin navigation group that contains this type.
iconnoIcon for the navigation entry.
title_fieldnoField whose value is shown as the record title.
publicnoServe published records at /api/v1/content/<id>. Types that are not public answer 404, exactly like unknown types.
draftsnoAdd a draft or published status. New records start as drafts and the public API never returns drafts.
revisionsnoKeep the last 50 saved versions of each record. Required when any field is localized.
These field ids are reserved because the storage layer adds them to every record: id, version, created_at, updated_at and locale.

YAML tips

  • The compact flow style - {id: title, label: Title, kind: text} keeps one field per line; use the expanded block style when a field has many options.
  • Comments are welcome and are the best place to explain why a field exists.
  • Commit the files. A content type file is part of your data model.
The complete reference is the header comment of internal/contenttypes/definition.go in the repository. Everything on these pages is derived from it.