# Defining Content

Before a piece of content can be created in the Umbraco backoffice, first it needs to be defined. That is why, when opening a blank installation of Umbraco, it is not possible to create content in the **Content** section.

All content needs a blueprint that holds information about what kind of data can be stored on the content node or which editors are used.

Additionally, it also needs information on how it is organized, where in the structure it is allowed, and so forth. This blueprint or definition is called a **Document Type**.

## What is a Document Type?

Document Types define what kind of content can be created in the **Content** section and what an end-user sees and can interact with.

It can define entire pages or more limited content that can be reused on other nodes ie. a Search Engine Optimization (SEO) group. This means that you are in complete control of what type of content can be created and where.

Another example is if there is a "`Blog post`" Document Type that has some properties containing a thumbnail, a name, and an author image. Then all blog posts using the "`Blog post`" Document Type, will allow the end user to fill in a thumbnail, author name, and an author image.

A Document Type contains fieldsets (or groups) where you can apply rules about where the content can be created, allowed template(s), backoffice icons, etc.

## 1. Creating a Document Type

A Document Type is created using the Document Type editor in the **Settings** section.

* Go to the **Settings** section in the backoffice.
* On the **Document Types** node click the menu icon (•••) to bring up the context menu.
* Here choose **Document Type with Template**. This will create a new Document Type with a template. The Template can be found under **Templates** in the **Settings** section which will be assigned as the default template for the Document Type.

![CreateDoctype](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-2ff143255d47ca5a591484791f41830cc7de2205%2FCreateDoctype.png?alt=media)

You can also choose to create a **Document Type** without a template and create **Folders** to organize your Document Types. Other options are to create Compositions and Element types, which you can read more about in the [Default Document Types](https://docs.umbraco.com/umbraco-cms/fundamentals/data/defining-content/default-document-types) section.

## 2. Defining the root node

### Name the Document Type

First, we're prompted to give the Document Type a **name**. This first Document Type will be the root node for our content, name it "`Home`".

![Name the Document Type](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-7c3e05f31d5509678458b5f3b8cf84755aac2534%2FhomePage.png?alt=media)

{% hint style="info" %}
The alias of the Document Type is automatically generated based on the property name. If you want to change the auto-generated alias, click the "**lock**" icon. The alias must be in camel case. For example: *`homePage`*.
{% endhint %}

Having a root node lets you quickly query content as you know everything will be under the root node.

### Adding Icons to the Document Type

Choosing appropriate icons for your content nodes is a good way to give editors a better overview of the content tree.

To set an icon for the Document Type click the document icon in the top left corner. This will open the icon select dialog. Search for "`Home"`and select the icon. This icon will be used in the content tree.

![Home icon](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-9383f25f90e3698e4efeda20ee28f9faf0e1daa6%2FdocTypeIcon.png?alt=media)

### Setting Permissions

This will allow this Document Type to be created as the first content in the **Content** section.

* Go to the **Structure** tab
* Tick the **Allow as root** toggle
* Save the Document Type by clicking **save** in the bottom right corner.

![Allow as root](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-03fcaca6107fb0f362fd1541b47190a4a5cf9376%2FdocTypePermissions.png?alt=media)

## 3. Creating the content

Now that we have the Document Type in place, we can create the content.

* Go to the **Content section**
* Click on the menu icon next to **Content**
* Select the "`Home`" Document Type. We'll name it "`Home`"
* Then click the **Save and Publish** button.

![Create homepage](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-d02e29e9be15fcf59b31f906cbc721371f79f211%2FcreateHomepage.png?alt=media)

As we haven't created our properties, all we can see on the "`Home`" node is the Properties tab. This tab contains the default properties that are available on all content nodes in Umbraco.

Let's add some properties of our own.

## 4. Groups and properties

In order to add the option to create different content on the same Document Type, some groups and properties need to be added.

**Groups**

Groups are a way to organize and structure the properties within the content, making it more manageable. It also makes it more user-friendly for content editors when creating or editing content on a website.

A name can be added to the group and after properties can be added.

**Properties**

Each field on a Document Type is called a property. The property is given a **name**, an **alias** (used to output the properties contained in a template), and an **editor**.

The editor determines what type of data the property will store and the input method. There is a wide range of default [property editors available](https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors) and you can [customize additional editors](https://docs.umbraco.com/umbraco-cms/customizing/property-editors).

Some editors require configuration where a configured editor is saved as a Data Type and can be reused for multiple properties and document types. These can be seen in the **Settings** section under **Data Types**.

* Go to the **Settings section**
* Expand **Document Types** by clicking the arrow to the left
* Select the "`Home`" Document Type.

{% hint style="info" %}
**Keyboard Shortcuts**

Keyboard shortcuts are available when you are working with the Document Type editor. To see which shortcuts are available, click **ALT + SHIFT + K**.
{% endhint %}

### Adding groups

Before we start adding properties to the Document Type we need to create a group to hold the property.

* Click **Add group** and name the group "`Content`".

<figure><img src="https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-aa1a9a634ccbe06f0a08ef0469889b9d7dfcea59%2Fimage%20(5).png?alt=media" alt="Creating groups"><figcaption><p>Creating groups</p></figcaption></figure>

{% hint style="info" %}
*If you have multiple groups and/or properties you can order them with drag and drop or by entering a numeric sort order value. This is done by clicking **Reorder**.*
{% endhint %}

To convert a group to a tab, see the [Convert a group to a tab](https://docs.umbraco.com/umbraco-cms/fundamentals/adding-tabs#convert-a-group-to-a-tab) section in the [Using Tabs](https://docs.umbraco.com/umbraco-cms/fundamentals/data/adding-tabs) article.

### Adding properties

Now that we have created a group we can start adding properties. Let's add a Rich Text editor to the Content group.

* Click the **Add property** link in the **Content** group. This opens the property settings dialog. Here you can set the metadata for each property (name, alias, description)
* **Choose** which Data Type/property editor to use, and add validation if needed.
* Give the property a **name.** The name will be shown to the editor to make it relevant and understandable. Notice the alias is automatically generated based on the name. We'll name this "`Body Text`".

![Adding a property](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-0fa9fd96537e07a1f6c6168047322076220737d5%2Faddproperty.png?alt=media)

#### Property Editors

* Clicking **Select Editor** will open the Select Editor dialog. Here, you can choose between all the available editors on the **Create a new Configuration** tab. This will create a new configuration or already configured editors in the **Available Configurations** tab.
* To make it easier to find what you need use the **search field** to filter by typing "`Rich`". Filtering will display configured properties first (under **Available configurations**) and all available editors under that.
* Select the **Rich Text editor** under **Create new**. This will let you configure the editor settings - the Rich Text editor for this property.

![Choosing the Rich Text editor](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-92e375529fc0f7b87a82483dcf67c282d327565a%2FselectEditor.png?alt=media)

{% hint style="info" %}
The name of the Data Type is based on the name of the Document Type, the name of the property, and the property editor. Flor example: *Home - Body Text - Rich Text editor*.
{% endhint %}

* Let's **rename** it to "`Basic Rich Text editor`" and only select the most necessary options.
  * `bold`
  * `italic`
  * `alignLeft`
  * `alignCenter`
  * `link`
  * `umbMediaPicker`
* When you are happy with the settings click **Submit**.

{% hint style="info" %}
Selecting the **Mandatory** toggle makes the property mandatory and the content cannot be saved if no value is entered (in this case, the Richtext editor).

You have the option to add additional validation by selecting a predefined validation method under the **Custom validation** dropdown (such as email, number, or URL). Or by selecting a custom validation and adding a regular expression.
{% endhint %}

* **Save** the Document Type.
* If you go to the **Content section** and click on the `Home node` you will now see the `Content`group with the `Body Text` property.

#### Property descriptions

The description of the property is not necessary, but it´s a best practice as it guides the editor to use the property correctly. The property description supports some markdown and one custom collapse syntax:

<details>

<summary><strong>Bold</strong></summary>

You can make text in the description bold by wrapping it with `**`

```md
This is **bold**
```

</details>

<details>

<summary><strong>Italic</strong></summary>

You can make text in the description italic by wrapping it with `*`

```md
This is *italic*
```

</details>

<details>

<summary><strong>Links</strong></summary>

You can make links by using the syntax:

```md
[This is an absolute link](https://umbraco.com/)
[This is a relative link](/umbraco/section/media)
```

**Note**: Links will always have the`target="_blank"` set. This is currently not configurable.

</details>

<details>

<summary><strong>Images</strong></summary>

You can embed images by using this syntax:

```md
![Image alt text](https://media.giphy.com/media/bezxCUK2D2TuBCJ7r5/giphy.gif)
```

</details>

<details>

<summary><strong>Collapsible description</strong></summary>

You can make the description collapsible by using this syntax:

```md
<details>
  <summary>This is displayed</summary>
  This is hidden.
</details>
```

</details>

Now if we put it all together we get something like this:

```md
This is **bold**
This is *italic*
[This is an absolute link](https://umbraco.com/)
[This is a relative link](/umbraco/section/media)
<details>
<summary>Read more</summary>

![Image alt text](https://media.giphy.com/media/bezxCUK2D2TuBCJ7r5/giphy.gif)

</details>
```

![Markdown description example](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-538e3c6f7af2e6a58c8ba34462d54e3a6545cc92%2Fmd-description-v17.gif?alt=media)

## 5. Defining child nodes

Next up we'll create a text page Document Type that will be used for subpages on the site.

* Go back to the **Settings section**
* **Create** a new Document Type
* **Name** it "`Text Page`".
* Add a **group** called "`Content`"
* This time we'll add two properties:
  * First, make a property called "`Summary`" using the **Textarea** editor
  * Secondly, create a property called "`Body Text`" and reuse the **Rich Text Editor** Data Type.

### Creating child nodes

Before creating a Text Page in **Content** section, allow the Text Page Document Type to be created as a child node to the Home node.

* **Select** the "`Home`" Document Type
* Go to the **Structure** group.
* Click **Add child**
* **Select** "`Text Page`".

<figure><img src="https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-eb4330ec76a04e8b1f196f101b73c4c148dacd4a%2Fimage%20(8).png?alt=media" alt="Allow Child page"><figcaption><p>Allow Child page</p></figcaption></figure>

* Go to the **Content** section
* Click the menu icon (•••) next to the "`Home`" node
* **Select** the "`Text page`" Document Type. We'll name the page "`About us`". We now have a basic content structure.

<figure><img src="https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-1a3dcaa872b5afc50685259f101dd7b06baf897f%2FcreateAboutUs.PNG?alt=media" alt=""><figcaption></figcaption></figure>

Document Types are flexible and can be used for defining pieces of reusable content or an entire page, to act as a container or repository.

## 6. Exporting/Importing the Document Type

You can also export document types from an already existing project/installation and import them into another project/installation.

* Go to the **Settings** section
* Click **...** next to the **Document type**
* Select **Export**. When you click on the **Export** button, the Document Type is saved as a \*.udt file.

![Exporting a Document Type](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-6aab567e14febad4d154ccafb071ec331cc57d65%2Fexport-document-type.png?alt=media)

To import a Document Type:

* Go to the **Settings** section
* Click **...** next to the **Document type**
* Select **Import Document Type**
* Click on the **Import** button and browse to the Document Type you exported. The **Name** and **Alias** of the Document Type are displayed.
* Click **Import** to complete the process.

![Importing a Document Type](https://2050077833-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fb0WSXUuM7Qx5BfREagAI%2Fuploads%2Fgit-blob-3450fc8287d729a275ebaaebc4abd45d61121b08%2Fimport-document-type.png?alt=media)

{% hint style="info" %}

1. If your Document Type contains compositions or inherits from another Document Type, then you need to export/import the Composition/Document Type too.
2. You cannot export/import document types on Umbraco Cloud.
   {% endhint %}

## More information

* [Rendering Content](https://docs.umbraco.com/umbraco-cms/fundamentals/design/rendering-content)
* [Customizing Data Types](https://docs.umbraco.com/umbraco-cms/fundamentals/data/data-types)

## Related Services

* [ContentService](https://apidocs.umbraco.com/v17/csharp/api/Umbraco.Cms.Core.Services.ContentService.html)
* [ContentTypeService](https://apidocs.umbraco.com/v17/csharp/api/Umbraco.Cms.Core.Services.ContentTypeService.html)

## Tutorials

* [Creating a basic website with Umbraco](https://docs.umbraco.com/umbraco-cms/tutorials/creating-a-basic-website)
