# Need to redefine the whole Outputs map when needing to set just one Kind?

**URL:** <https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953>\
**Category:** support\
**Created:** [March 8, 2018, 8:00pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953 "2018-03-08T20:00:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 8, 2018, 8:00pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/1 "2018-03-08T20:00:10Z")

</div>

Hello,

After adding this to my `config.toml`:

```toml
[Outputs]
  home = ["HTML", "RSS", "JSON"] # default: home = ["HTML", "RSS"]

```

The RSS feed for sections, tags, etc. stopped generating…

So `mydomain.com/tags/foo/index.xml` would return 404.

But if I comment out that whole Outputs customization, that same feed will generate fine.

Then looking at the documentation:

> **[Custom output formats](https://gohugo.io/templates/output-formats/#output-formats-for-pages)**
>
> Hugo can output content in multiple formats, including calendar events, e-book formats, Google AMP, and JSON search indexes, or any custom text format.

… there’s an innocuous looking line:

> Any `Kind` without a definition will default to `HTML`.

!!

This is the workaround I use right now… just to get `JSON` output format added to `home` Kind… which looks like an overkill.

```toml
[Outputs]
  home = ["HTML", "RSS", "JSON"] # default: home = ["HTML", "RSS"]
  section = ["HTML", "RSS"]
  taxonomy = ["HTML", "RSS"]
  taxonomyTerm = ["HTML", "RSS"]

```

Tomorrow if more kinds are added to outputformats, I would need to add even that to all my sites.

Can this feature request be considered:

**If customizing the output formats for one Kind, leave the output formats for other Kinds at their default values.**

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 8, 2018, 9:12pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/2 "2018-03-08T21:12:06Z")

</div>

> [@kaushalmodi](#):
>
> If customizing the output formats for one Kind, leave the output formats for other Kinds at their default values.

That would be a breaking change, which is always problematic. But it is also a change I don’t agree with. Which is obviously why it is implemented the way it is.

The default outputs config had HTML + RSS so that existing sites would continue to work as is. If you provide your own config, you tell Hugo that you want your own custom config. There is nothing particularly special about the RSS output type, and HTML is added as the one single default just because Hugo kind of does not work without at least one.

So, if you want an RSS for taxonomies, go ahead and configure it. But I don’t want that, so I don’t see why I should have to do anything special about it.

> [@kaushalmodi](#):
>
> Tomorrow if more kinds are added to outputformats,

More kinds? I don’t see how we have any more kinds that RSS is relevant for, and it would probably be surprising to people if we added some new “kind” and a new RSS feed just popped up.

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 8, 2018, 9:21pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/3 "2018-03-08T21:21:40Z")

</div>

Thanks for the reply.

> [@bep](#):
>
> if you want an RSS for taxonomies, go ahead and configure it.

Yes, I see that as a good solution moving forward.

> [@](#):
>
> But I don’t want that, so I don’t see why I should have to do anything special about it.

The behavior is surprising, because if you do not set the `Outputs` in config.toml, RSS feeds get generated by default for sections, taxonomies, etc. (this is also mentioned in [docs](http://gohugo.io/templates/output-formats/#output-formats-for-pages) as _By default, all pages will render as HTML with some of them also as RSS (homepage, sections, etc.)._). But then if I specify the Outputs for `home`, section, taxonomy, etc. Outputs get stripped down to just `HTML`.

So we kind of see a _hysteresis_ over here… initial untouched default (_ **Edit** : I mean if user has not customized the `Outputs` variable at all in their site config_) includes RSS for sections, but once Outputs is touched, the default changes to include only HTML.

If this is a backward incompatible change, I can understand… but let me open an issue to at least document this behavior more prominently.

Related question:

Also for documentation, what are the default outputs for all kinds if user hasn’t configured outputs at all in their config.toml?

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 8, 2018, 9:23pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/4 "2018-03-08T21:23:21Z")

</div>

> [@kaushalmodi](#):
>
> Outputs is touched,

Output **is set**. Which is a semantic difference.

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 8, 2018, 9:24pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/5 "2018-03-08T21:24:34Z")

</div>

> [@](#):
>
> Output is set. Which is a semantic difference.

I should have been clearer… I meant if user has not configured the Outputs var in their site config.

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 8, 2018, 9:31pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/6 "2018-03-08T21:31:40Z")

</div>

OK, I figured out the default if user has not set `outputs`:

> <https://github.com/gohugoio/hugo/blob/9ac62065840aa27c6e35ed3348fb76aa1288eff2/hugolib/site_output.go#L74-L78>

So the question is that why is the default set to to `HTML` for **all** Kinds if user has set the `outputs` for only one of the Kinds.

It would be less surprising if the default for all Kinds before setting `outputs` and after setting `outputs` stayed the same.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 8, 2018, 9:55pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/7 "2018-03-08T21:55:27Z")

</div>

> [@kaushalmodi](#):
>
> So the question is that why is the default set to to HTML f

One reason: Hugo would crash without at least one output format for a given kind.

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 8, 2018, 10:00pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/8 "2018-03-08T22:00:43Z")

</div>

> [@bep](#):
>
> One reason: Hugo would crash without at least one output format for a given kind.

Yes, I understand that part… the question is… why not set the defaults as [`createDefaultOutputFormats`](https://github.com/gohugoio/hugo/blob/9ac62065840aa27c6e35ed3348fb76aa1288eff2/hugolib/site_output.go#L67) is doing?

Probably I am reading the code wrong, but looks like the setting of defaults after user sets `outputs` is done [here](https://github.com/gohugoio/hugo/blob/9ac62065840aa27c6e35ed3348fb76aa1288eff2/hugolib/site_output.go#L57-L59). Inside `createDefaultOutputFormats` we have a `if kind != KindPage {` clause which is missing in the alternative default setting code I linked in the “here” above.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 8, 2018, 10:06pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/9 "2018-03-08T22:06:09Z")

</div>

Are you saying that the code looks different compared to how it behaves?

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 8, 2018, 10:14pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/10 "2018-03-08T22:14:11Z")

</div>

No… it obviously behaves as coded… but I wouldn’t have known that without reading the code… and also the coded behavior is surprising.

Let me give an example:

### User has not set `outputs` in site config initially

So this is what the `outputs` will get set automatically by default, using `createSiteOutputFormats` (which would be equivalent to below in site config):

**INIT BLOCK**

```auto
[outputs]
  page = ["HTML"]
  home = ["HTML", "RSS"]
  section = ["HTML", "RSS"]
  taxonomy = ["HTML", "RSS"]
  taxonomyTerm = ["HTML", "RSS"]
  ...

```

### Now user sets only the `home` in `outputs` in site config

… to set the JSON output too for search index.

```auto
[outputs]
  home = ["HTML", "RSS", "JSON"]

```

That in turns wipes out the RSS format from everything not set by the user!

```auto
[outputs]
  page = ["HTML"]
  home = ["HTML", "RSS", "JSON"]
  section = ["HTML"] # why is this touched?
  taxonomy = ["HTML"] # why is this touched?
  taxonomyTerm = ["HTML"] # why is this touched?
  ...

```

Ideally the resultant `outputs` should have been:

```auto
[outputs]
  page = ["HTML"] # same value as in INIT BLOCK
  home = ["HTML", "RSS", "JSON"] # user modified value
  section = ["HTML", "RSS"] # same value as in INIT BLOCK
  taxonomy = ["HTML", "RSS"] # same value as in INIT BLOCK
  taxonomyTerm = ["HTML", "RSS"] # same value as in INIT BLOCK
  ...

```

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 8, 2018, 10:18pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/11 "2018-03-08T22:18:59Z")

</div>

The kind of behaviour I would expect is as if:

- `createSiteOutputFormats` first gets set to the value returned by `createDefaultOutputFormats` **unconditionally**.
- Then, if user has _set_ `outputs` in their site config, update the value of `outputs` map internally **only** for the keys that the user set, and **only if** the key value if non-nil (non-empty or whatever the correct semantic term is).

The logic is basically _first set the sane non-empty defaults, then update only the keys the user set for which the value is non-empty._

The issue we have at the moment is that we are setting different values of defaults for these 2 scenarios:

- One where the user does not set `outputs` at all.
  - Using the `createDefaultOutputFormats` function.

- Another where the user updates the `outputs` only for selected few Kinds.
  - Using the 3 line `range` loop that does not have the special clause for kinds != page.

* * *

I hope the case I make is clearer now.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 9, 2018, 8:20am UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/12 "2018-03-09T08:20:16Z")

</div>

I understand where you are coming from, but the current implementation (which Is deliberate) is coming from the idea that

- You **set the output formats** map. This is analogous to setting the `related` config and the `sitemap` config and the `permalinks` config. You have to provide the complete definition.
- There is nothing particularly special about the RSS output format. I think that getting it by default for each list node in the tree would be surprising to many who take their time to “configure their own”.
- We need at least one, so we have HTML as a fall back (not default, a fall back). I assume we can agree that it makes more sense to use HTML than RSS as that one fallback option.
- And: Changing this behaviour would be a breaking change. I would do it if I thought it was a really good idea, but I’m not convinced.

Maybe others will chime in with their thoughts.

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 9, 2018, 4:32pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/13 "2018-03-09T16:32:20Z")

</div>

> [@bep](#):
>
> You set the output formats map. This is analogous to setting the related config and the sitemap config and the permalinks config. You have to provide the complete definition.

OK, I will buy it as long as there is consistency. It’s just that the implementation is different from my way of thinking. I think of setting a key in a map as modifying **just that key**. But the current hugo implementation considers that as setting that key **and resetting all the other keys not set**.

So I will update the documentation on Ouput Formats listing the default value set by `createSiteOutputFormats`.

* * *

**Update** : Submitted PR

> <https://github.com/gohugoio/hugoDocs/pull/404/files>
>
> \*\*Merge AFTER v0.38 release\*\*
> 
> Updates Output Formats documentation as per the… change in v0.38.

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 9, 2018, 4:47pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/14 "2018-03-09T16:47:46Z")

</div>

@bep I believe I should leave out the “other” Kinds ( `[]string{kindRSS, kindSitemap, kindRobotsTXT, kind404}` [ref](https://github.com/gohugoio/hugo/blob/9ac62065840aa27c6e35ed3348fb76aa1288eff2/hugolib/page.go#L56)) from the Output Formats documentation?

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 9, 2018, 6:06pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/15 "2018-03-09T18:06:32Z")

</div>

Yes, I made a mental note about the current implementation (which includes all kinds) – which includes those, but it has no practical implications.

Note that the current implementation is according to my head. If you somehow can gather support for your view on this that shows that I’m in clear minority on this, I will take a second look on it.

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 9, 2018, 6:09pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/16 "2018-03-09T18:09:11Z")

</div>

> [@bep](#):
>
> If you somehow can gather support for your view on this that shows that I’m in clear minority on this, I will take a second look on it.

Thanks. As I mentioned earlier, I am buying this logic as it is consistent. And so I have also opened that PR that clarifies the Page Kind concept that go hand in hand with understanding the default value of `outputs`, and what happens when a user modifies just one `outputs` Kind.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 9, 2018, 6:23pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/17 "2018-03-09T18:23:48Z")

</div>

Also note that I’m about to break the above “pattern” with the new “frontmatter” config section.

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 9, 2018, 6:32pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/18 "2018-03-09T18:32:36Z")

</div>

That’s not good… would be nice to have consistency.

Also, I never understood why my suggestion would be a breaking change. It’s not as if the Hugo builds will start failing… only that RSS pages will be generated when they were getting generated before. And anyways those RSS pages get generated for people who don’t set outputs.

So the people who did not want RSS would have already set the outputs to do so, and my proposed change will have no effect on them.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 9, 2018, 6:36pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/19 "2018-03-09T18:36:59Z")

</div>

> [@kaushalmodi](#):
>
> Also, I never understood why my suggestion would be a breaking change

You will start building RSS for people that did not have it before. It is not a glass breaking change, and I would not think too hard about doing it, if I felt if was right.

The frontmatter is a little bit different beast. We need some defaults for the dates. It is probably comparable to the `mediaTypes`. You can add/override.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 9, 2018, 6:59pm UTC](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953/20 "2018-03-09T18:59:36Z")

</div>

> <https://github.com/gohugoio/hugoDocs/issues/408>

[Next page](https://discourse.gohugo.io/t/need-to-redefine-the-whole-outputs-map-when-needing-to-set-just-one-kind/10953.md?page=2)
