Can default taxonomy destinations be disabled?

From Taxonomies | Hugo :

Default destinations

When taxonomies are used—and taxonomy templates are provided—Hugo will automatically create both a page listing all the taxonomy’s terms and individual pages with lists of content associated with each term. For example, a categories taxonomy declared in your configuration and used in your content front matter will create the following pages:

How do I disable the generation of pages for a particular taxonomy and terms (not all taxonomies)? In my case, I have an authors taxonomy for keeping track of who wrote which page, and also to associate email and website parameters with each author for the RSS/Atom feeds, but I dont want /authors/ and /authors/foo/ pages to be generated.

The general question seems to be answered in the next section on that page.

If that doesn’t fit your use case you might need to provide more context.

I’ve read that section, and I don’t think it does. Please quote what you’re referring to. That section explains how to remove the categories and tags taxonomies, and how to add additional taxonomies; it doesn’t show how to add taxonomies, but prevent generating output pages for them.

I put my exact scenario in my post:

In my case, I have an authors taxonomy for keeping track of who wrote which page, and also to associate email and website parameters with each author for the RSS/Atom feeds, but I dont want /authors/ and /authors/foo/ pages to be generated.

Can you please demonstrate how that section enables this?

so for the authors taxonomy you want

  • RSS feed
  • NO taxonomy pages

and for all other taxonomies you want both

right?

if so, you could deal with the output formats and create an /content/authors/_index.md containing

---
cascade:
   outputs:
      - RSS
---

which will be rendered as:

public
│   index.html
│   index.xml
│
├───authors
│   │   index.xml
│   │
│   └───me
│           index.xml
│
├───categories
│       index.html
│       index.xml

inspired by: How to disable RSS outputs everywhere except for one page?

In your site configuration, this will allow you to access term metadata, but Hugo will not render the authors taxonomy or term pages:

[[cascade]]
[cascade.build]
render = 'never'
[cascade._target]
path = '{/authors,/authors/**}'

After doing the above you can still access term metadata with something like this:

{{ with site.Taxonomies.authors.Get "author-a" }}
  Name: {{ .Page.Title }}<br>
  Email: {{ .Page.Params.email }}<br>
{{ end }}

Or this:

{{ with site.GetPage (printf "/authors/author-a") }}
  Name: {{ .Title }}<br>
  Email: {{ .Params.email }}<br>
{{ end }}
3 Likes

@jmooring I tried both

[[cascade]]
[cascade._target]
path = '{/authors,/authors/**}'
[cascade.build]
render = 'never'

and

[[cascade]]
[cascade._target]
path = '/authors/'
[cascade.build]
render = 'never'

[[cascade]]
[cascade._target]
path = '/authors/**'
[cascade.build]
render = 'never'

but neither worked; both http://localhost:1313/authors/ and http://localhost:1313/authors/foo/ are navigable with hugo server. Although I noticed that the term URL for http://localhost:1313/authors/foo/ on http://localhost:1313/authors/ was blank with either configuration.


@irkode “Authors” is a taxonomy, not a category term, e.g. /authors/john-smith/, not /categories/authors/. All output files—HTML/RSS/Atom—should be omitted. The taxonomy is purely for “backend” purposes, like filling in the author contact info for pages under /blog/ in an RSS/Atom feed.

I tried this in content/authors/_index.md:

outputs: []
cascade:
   outputs: []

but nothing changed.

I suggest you compare what you have done with this example:

git clone --single-branch -b hugo-forum-topic-50326 https://github.com/jmooring/hugo-testing hugo-forum-topic-50326
cd hugo-forum-topic-50326
hugo server

Works great.

Deleting public and resources fixed it. That seems like a bug.

This is not a bug. The behavior is expected. We do not clear the public directory when building a site. If you don’t like the behavior and have a static directory in the root of your project, use the --cleanDestinationDir CLI flag when building your site.

Thanks. Good to know.

sorry , two problems on my side here.

“Authors” is a taxonomy, not a category term, e.g. /authors/john-smith/, not /categories/authors/. All output files—HTML/RSS/Atom—should be omitted. The taxonomy is purely for “backend” purposes, like filling in the author contact info for pages under /blog/ in an RSS/Atom feed.

  1. first the wording it should have beend taxonomy in my post (updated it just for clarity):

    defined in hugo.toml as:

    [taxonomies]
       category   = 'categories'
       author     = 'authors'
    
  2. I fell over the first definition and though the RSS for authors is needed.

    disabling all is not possible with the outputs definition

Sry for the inconvenience

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.