| 1 |
--- |
| 2 |
title: Configure content types |
| 3 |
linkTitle: Content types |
| 4 |
description: Configure content types. |
| 5 |
categories: [] |
| 6 |
keywords: [] |
| 7 |
--- |
| 8 |
|
| 9 |
{{< new-in 0.144.0 />}} |
| 10 |
|
| 11 |
Hugo supports six [content formats](g): |
| 12 |
|
| 13 |
{{% include "/_common/content-format-table.md" %}} |
| 14 |
|
| 15 |
These can be used as either page content or [page resources](g). When used as page resources, their [resource type](g) is `page`. |
| 16 |
|
| 17 |
Consider this example of a [page bundle](g): |
| 18 |
|
| 19 |
```tree |
| 20 |
content/ |
| 21 |
└── example/ |
| 22 |
├── index.md <-- content |
| 23 |
├── a.adoc <-- resource (resource type: page) |
| 24 |
├── b.html <-- resource (resource type: page) |
| 25 |
├── c.md <-- resource (resource type: page) |
| 26 |
├── d.org <-- resource (resource type: page) |
| 27 |
├── e.pdc <-- resource (resource type: page) |
| 28 |
├── f.rst <-- resource (resource type: page) |
| 29 |
├── g.jpg <-- resource (resource type: image) |
| 30 |
└── h.png <-- resource (resource type: image) |
| 31 |
``` |
| 32 |
|
| 33 |
The `index.md` file is the page's content, while the other files are page resources. Files `a` through `f` are of resource type `page`, while `g` and `h` are of resource type `image`. |
| 34 |
|
| 35 |
When you build a site, Hugo does not publish page resources having a resource type of `page`. For example, this is the result of building the site above: |
| 36 |
|
| 37 |
```tree |
| 38 |
public/ |
| 39 |
├── example/ |
| 40 |
│ ├── g.jpg |
| 41 |
│ ├── h.png |
| 42 |
│ └── index.html |
| 43 |
└── index.html |
| 44 |
``` |
| 45 |
|
| 46 |
The default behavior is appropriate in most cases. Given that page resources containing markup are typically intended for inclusion in the main content, publishing them independently is generally undesirable. |
| 47 |
|
| 48 |
The default behavior is determined by the `contentTypes` configuration: |
| 49 |
|
| 50 |
{{< code-toggle config=contentTypes />}} |
| 51 |
|
| 52 |
In this default configuration, page resources with those media types will have a resource type of `page`, and will not be automatically published. To change the resource type assignment from `page` to `text` for a given media type, remove the corresponding entry from the list. |
| 53 |
|
| 54 |
For example, to set the resource type of `text/html` files to `text`, thereby enabling automatic publication, remove the `text/html` entry: |
| 55 |
|
| 56 |
{{< code-toggle file=hugo >}} |
| 57 |
contentTypes: |
| 58 |
text/asciidoc: {} |
| 59 |
text/markdown: {} |
| 60 |
text/org: {} |
| 61 |
text/pandoc: {} |
| 62 |
text/rst: {} |
| 63 |
{{< /code-toggle >}} |