HUGO
News Docs Themes Community GitHub

Configure outputs

Configure which output formats to render for each page kind.

An output format is a collection of settings that defines how Hugo renders a file when building a site. For example, html, json, and rss are built-in output formats. You can create multiple output formats and control their generation based on page kind, or by enabling one or more output formats for specific pages.

Learn more about creating and configuring output formats in the configure output formats section.

Outputs per page kind

The following default configuration determines the output formats generated for each page kind:

outputs:
  home:
  - html
  - rss
  page:
  - html
  rss:
  - rss
  section:
  - html
  - rss
  taxonomy:
  - html
  - rss
  term:
  - html
  - rss
[outputs]
  home = ['html', 'rss']
  page = ['html']
  rss = ['rss']
  section = ['html', 'rss']
  taxonomy = ['html', 'rss']
  term = ['html', 'rss']
{
   "outputs": {
      "home": [
         "html",
         "rss"
      ],
      "page": [
         "html"
      ],
      "rss": [
         "rss"
      ],
      "section": [
         "html",
         "rss"
      ],
      "taxonomy": [
         "html",
         "rss"
      ],
      "term": [
         "html",
         "rss"
      ]
   }
}

To render the built-in json output format for the home page kind, assuming you’ve already created the necessary template, add the following to your configuration:

outputs:
  home:
  - html
  - rss
  - json
[outputs]
  home = ['html', 'rss', 'json']
{
   "outputs": {
      "home": [
         "html",
         "rss",
         "json"
      ]
   }
}

Notice in this example that we only specified the home page kind. You don’t need to include entries for other page kinds unless you intend to modify their default output formats.

The order of the output formats in the arrays above is important. The first element will be the primary output format for that page kind, and in most cases that should be html as shown in the default configuration.

The primary output format for a given page kind determines the value returned by the Permalink and RelPermalink methods on a Page object.

See the link to output formats section for details.

Outputs per page

Add output formats to a page’s rendering using the outputs field in its front matter. For example, to include json in the output formats rendered for a specific page:

---
outputs:
- json
title: Example
---
+++
outputs = ['json']
title = 'Example'
+++
{
   "outputs": [
      "json"
   ],
   "title": "Example"
}

In its default configuration, Hugo will render both the html and json output formats for this page. The outputs field appends to, rather than replaces, the site’s configured outputs.