# Granular Output Configuration

**URL:** <https://discourse.gohugo.io/t/granular-output-configuration/50255>\
**Category:** tips & tricks\
**Tags:** taxonomy\
**Created:** [June 11, 2024, 8:29pm UTC](https://discourse.gohugo.io/t/granular-output-configuration/50255 "2024-06-11T20:29:45Z")\
**Posts on this page:** 3\
**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:** [June 11, 2024, 8:29pm UTC](https://discourse.gohugo.io/t/granular-output-configuration/50255/1 "2024-06-11T20:29:45Z")

</div>

Did you know you can disable rendering of taxonomy/term pages by simply creating an empty layout file?

I discovered this lifesaver after trying and failing to find a configuration-based approach. Since Google came up dry in my journey, I’ll share my story here in the hopes that it helps someone else down the road.

We’re taking advantage of some custom output formats to serve structured data for certain taxonomies/terms. For instance, creating JSON output for our `years` taxonomy, listing all available terms (years) and, for each term, all available posts. We achieve this with Hugo’s extensible output formats feature. Here’s an example from our hugo.yaml:

```auto
outputFormats:
  calendar:
    baseName: calendar
    isPlainText: true
    mediaType: application/json
outputs:
  taxonomy:
    - html
    - calendar
  term:
    - html
    - calendar

```

This was working great for our purposes, but as our site content grew (1000+ pages, 8 taxonomies), build times started creeping up fast, at one point taking more than 30 seconds for the initial build.

Examining the _/public_ directory, I noticed that every single taxonomy and term had a _calendar.json_ file being rendered. All because one of our eight taxonomies needed it.

To solve this, I first tried moving the _list.calendar.json_ and _terms.calendar.json_ files from _/layouts/\_default_ to _/layouts/years_. This solved the issue of extraneous pages being rendered, but then Hugo started throwing warnings at build time to let me know I was missing default layouts.

On a hunch, I created empty layout files in the _/layouts/\_default_ directory. This made the warnings go away, which is great! I then presumed I would find empty _calendar.json_ files all over the place in the _/public_ folder. But no, it turns out Hugo detects the empty file and skips it altogether! Yay!

That’s when I realized I could use the same approach to selectively disable HTML listing pages for taxonomies and terms. So I went through our taxonomies and disabled several templates we never use on our site. When I was finished, I purged the _/public_ directory and ran a full build. Total build time went from \>30s to _under 7 seconds_!

I hope this helps someone else improve their build times and clean up their output folders.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 11, 2024, 8:34pm UTC](https://discourse.gohugo.io/t/granular-output-configuration/50255/2 "2024-06-11T20:34:38Z")

</div>

Typically you would handle this with build or cascade options. Was there a reason that wouldn’t work in this case?

For example, this…

```plaintext
[taxonomies]
author = 'authors'
category = 'categories'
tag = 'tags'

[outputs]
taxonomy = ['html']
term = ['html']

[[cascade]]
outputs = ['html','calendar']
[cascade._target]
path = '{/authors,/authors/**}'

```

…produces this:

```plaintext
public/
├── authors/
│ ├── author-a/
│ │ ├── index.html
│ │ └── index.ics
│ ├── author-b/
│ │ ├── index.html
│ │ └── index.ics
│ ├── index.html
│ └── index.ics
├── categories/
│ ├── category-a/
│ │ └── index.html
│ ├── category-b/
│ │ └── index.html
│ └── index.html
├── tags/
│ ├── tag-a/
│ │ └── index.html
│ ├── tag-b/
│ │ └── index.html
│ └── index.html
├── favicon.ico
├── index.html
├── index.xml
└── sitemap.xml

```

In the above notice that only the authors taxonomy/term pages have the calendar output format.

---

<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:** [June 12, 2024, 3:35pm UTC](https://discourse.gohugo.io/t/granular-output-configuration/50255/3 "2024-06-12T15:35:51Z")

</div>

Wow, this is a great solution, and one that I managed to miss completely while searching & browsing the docs. Thanks!
