Reduce Rendering of Term pages for Specific Taxonomy, Type, or Content Adapter Type

This is not a new topic, it’s a reference to the link below. I added here because the link below is getting buried.

I’m sure you guys are busy and I want to thank you for the time and effort you put in to not only building Hugo, but also responding to people’s questions.

Joe Mooring has posted a lot of great tips and tricks, and also answered a few of my questions in the past.

It seems likely you would have specified Create a ‘new’ Topic, because you have a system in place for bumping updated topics.

Just mention if you want me to put this on the original topic page. I will mark this solved and move to the original one.

I’m still looking for ways to reduce taxonomy html output for a specific page type, or taxonomy, while still using the related taxonomy functionality during build time.

Presumably, it’s not that big a deal, in terms of reducing build time, but rendering the tags pages and the <head> partial in all the pages take by far the most time in the build.

In terms of the adapter, I’m looking to override the terms page, which doesn’t seem possible.

Here is the example for a standard adapter page, skipping the loop and other content:

<!-- tags -->
{{- $tags := slice -}}
{{- $tagTermsSlice := slice -}}

{{- with $entries.tags -}}

{{- range . -}}
{{- $tags = $tags | append  ( . | safeURL) -}}
{{- $tagTermsSlice = $tagTermsSlice | append (dict "kind" "term" "path" ( (printf `%s%s` "tags/" . ) | safeURL) "build" (dict "render" "never") ) -}}
{{- end -}}

{{- end -}}

{{/* $dates, $params, $path, etc  .... */}}

{{ $page := dict
    "dates" $dates
    "kind" "page"
    "params" $params
    "path" $path
    "title" $title
}}

{{ $.AddPage $page }}

{{- with $tagTermsSlice -}}
{{- range . -}}
{{- $.AddPage . -}}
{{- end -}}
{{- end -}}

The idea is to override the term page for each tag the content adapter creates by matching the path, adding “kind” “term” and then specifying in the build dictionary to never render.

Possibly if I knew more about what you guys were doing under the hood, I would even bother with that :smile:

But I did not see the option to specify taxonomy output rendering restrictions by filtered data, just the all or nothing options:

disableKinds = ['taxonomy', 'term']


[taxonomies]
  category = ''
  tag = ''

Any hints or feedback?

What you ask for isn’t entirely clear for me, but you may have a look at Build options | Hugo

Combine this with cascade… maybe.

Thanks for your reply. I’m turning Json files into pages using the content adapter.

Before the html output is created, I’m referencing those pages from other pages, and extracting params data, like an image url, title, etc.

Joe demonstrated how to ‘not’ render pages for that given adapter here:

In this case, I’d like to build the pages, but not render taxonomy pages.

In other words, if the json file has an entry with "tags": "[\"example-tag\"]",,

In public/tags/ gets this structure:

Because there are many of them, and they take a lot of time build, I’d rather Hugo skips creating the ‘example-tag’ folder.

Anyway, I think this is what you are suggesting:


{{ $taxonomyPage := dict
    "kind" "taxonomy"
    "path" (printf `%s` "tags/")
    "cascade.build" (dict "render" "never" "list" "never" "publishResources" "false")

}}
{{- $.AddPage $taxonomyPage -}}

That didn’t do it, but I will play around that and see if I get it

If I get it right:

  • you create a page with given tags using a content adapter
  • you don’t want the term page for the these tags to be rendered

To use the whole taxony linking stuff you need a page, but you can supress the rendering and listing.

Pages created by the content adapter are relative, so you may not handle a term page in the posts section.

a second content/tags/_content.gotmpl might help

{{ $content := dict
   "mediaType" "text/markdown"
   "value" "The tag page for black"
}}
{{ $page := dict
   "content" $content
   "kind" "term"
   "path" "black"
   "title" "Tag Black"
   "build" (dict "render" "never" "list" "never")
}}
{{ .AddPage $page }}

maybe add a custom parameter like “hidden_tag” true, so you can identify those tags when working with tags in other templates.

I tested this a few times, and didn’t get the result I wanted. The tags html files were printed anyway. I’ve had to deprioritized it. Will update if there is movement on it again.

maybe also then take the time for a second thought on using tags for that.

if it’s much effort to tune a system to behave different from it’s designed purpose it might be better to handle your requirements with enhancing non tags to behave as you want. or a mixture. of both.