Skip to content
Strife Docs

Reference

Templates

Templates in Strife serve as the foundation for creating structured and consistent content. These predefined templates establish the fields, and structure, for all content stored in the database.

There are two types of templates in Strife; Document Templates and Content Templates.

Document Templates

The Document Template serves as template for creating documents in the database. It can incorporate various fields types to meet diverse needs.

In addition to defining the fields and structure, there are several other significant aspects of the document template worth exploring.

Collection

The document template specifies the collection name, which is utilized to query the database for all content created using that particular template. This collection name is assigned during template creation and is stored within the metadata section of each document in the database.

JSON
"@metadata": {
    "@collection": "Posts",
    ...
}
Note:

If you are using C#, the collection name is stored alongside the Type property to facilitate model binding and serialization. For detailed instructions on setting up model binding in C#, please consult this provided tutorial.

Note:

The Collection plays a crucial role in utilizing and comprehending RavenDB. For a deeper understanding of RavenDB, please explore additional resources available here.

Enable URL

When creating the document template, you have the option to enable or disable the indexing of content URLs. When enabled, content created from the template is treated as web pages, and a URL is automatically generated and indexed based on the content's slug and hierarchy. This enables easy web access to the content. When disabled, the content is accessible solely by querying the database or referencing from other content.

Note:

For additional details on the URL indexing, please refer to this resource.

Content Templates

The Content Template serves as a reusable preset of fields designed for integration within a Document Template or a Chapters field. It's important to note that a Content Template is not meant for creating documents in the database. Instead, any content generated from a Content Template is always stored within the document that uses that particular Content Template.

Creating templates

Templates can be created either through the graphical interface under Settings in Strife Studio, or by creating and deploying source-controlled JSON templates.