# Using OutputFormats to generate config.yml in a certain section?

**URL:** <https://discourse.gohugo.io/t/using-outputformats-to-generate-config-yml-in-a-certain-section/52308>\
**Category:** support\
**Tags:** configuration\
**Created:** [November 6, 2024, 4:33pm UTC](https://discourse.gohugo.io/t/using-outputformats-to-generate-config-yml-in-a-certain-section/52308 "2024-11-06T16:33:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![njbair](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/njbair/32/15607_2.png) [@njbair](https://discourse.gohugo.io/u/njbair)\
**Post date:** [November 6, 2024, 4:33pm UTC](https://discourse.gohugo.io/t/using-outputformats-to-generate-config-yml-in-a-certain-section/52308/1 "2024-11-06T16:33:39Z")

</div>

I’m looking to achieve the following output in my build:

```auto
public/
├── admin/
│ ├── index.html
│ └── config.yml
...

```

…where _config.yml_ is dynamically generated via a custom output format.

So far, I’ve tried to achieve this with the following content structure:

```auto
content/
├── admin/
│ ├── _index.md
│ └── config.md
layouts/
├── admin/
│ ├── admin.html
│ └── single.adminconfigyaml.yml
...

```

_hugo.toml_:

```toml
[outputFormats]
  [outputFormats.AdminConfigYaml]
    baseName = 'config'
    isPlainText = true
    mediaType = 'application/yaml'

```

\_/content/admin/_index.md_:

```toml
+++
title = "Admin"
+++

```

_/content/admin/config.md_:

```toml
+++
title = 'Config'
outputs = ['AdminConfigYaml']
+++

```

The _index.html_ builds just fine, but I get a warning regarding the config file:

```plaintext
WARN found no layout file for "adminconfigyaml" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

```

It seems to me that, for the purposes of Hugo’s template lookup order, _content/admin/config.md_ would be a _single page in “admin” section_ with OutputFormat _AdminConfigYaml_ and suffix _yml_, in which case the filename _layouts/admin/single.adminconfigyaml.yml_ should work.

Any ideas where I went wrong?

[Demo Repo](https://github.com/njbair/hugo-template-lookup.git)

For those who are curious, my goal is to dynamically generate the config file for Sveltia, a drop-in replacement for Decap CMS (formerly Netlify CMS).

---

<div class="post-metadata">

**Author:** ![njbair](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/njbair/32/15607_2.png) [@njbair](https://discourse.gohugo.io/u/njbair)\
**Post date:** [November 6, 2024, 4:51pm UTC](https://discourse.gohugo.io/t/using-outputformats-to-generate-config-yml-in-a-certain-section/52308/2 "2024-11-06T16:51:01Z")

</div>

**Update** : I’ve discovered the issue.

I renamed the template file from _single.adminconfigyaml.yml_ to _single.adminconfig. **yaml** _, and the build worked as expected.

Unfortunately, that still didn’t help me because the resulting output file was _config.yaml_, and my admin backend expects it to have the _.yml_ extension.

To solve this, I tried redefining the `application/yaml` media type in my Hugo config, as follows:

```toml
[mediaTypes]
  [mediaTypes.'application/yaml']
    suffixes = ['yaml', 'yml']

```

This still did not work. So I switched the order of the suffixes in the config:

```toml
[mediaTypes]
  [mediaTypes.'application/yaml']
    suffixes = ['yml', 'yaml']

```

This worked! Which is great, but it got me curious, so I tried renaming the template again to use the _.yaml_ suffix. This time, I got the same warning about a missing layout file.

So it appears that, **in cases where multiple suffixes are specified for the mediaType, Hugo only acknowledges the first one**.

@bep is this a bug?

---

<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:** [November 6, 2024, 5:05pm UTC](https://discourse.gohugo.io/t/using-outputformats-to-generate-config-yml-in-a-certain-section/52308/3 "2024-11-06T17:05:45Z")

</div>

> [@njbair](#):
>
> @bep is this a bug?

No it isn’t. The media type definitions are used for a lot of “things” inside Hugo. We have multiple suffixes fo help going from filename =\> media type. The layout logic uses the first suffix. You could argue that we should try all of them, but it’s not a bug, it was deliberate to simplify the implementation.

---

<div class="post-metadata">

**Author:** ![njbair](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/njbair/32/15607_2.png) [@njbair](https://discourse.gohugo.io/u/njbair)\
**Post date:** [November 6, 2024, 5:39pm UTC](https://discourse.gohugo.io/t/using-outputformats-to-generate-config-yml-in-a-certain-section/52308/4 "2024-11-06T17:39:43Z")

</div>

Understood. Although the docs could be clearer on this point, especially since the media types are [listed on the Output Formats docs page](https://gohugo.io/templates/output-formats/#media-types).

Should I go ahead and file a PR to update the docs?
