Can we add extra data to TaxonomyTerm?

I’m setting up a site structure where I like to attach some extra data to some taxonomy terms (in addition to their name), to be able to use this data during rendering of the term under the list or single templates.

An example of such data would be like a “subtitle” or “short-description” / “summary” for the term.

It’s great that we can do that for pages, and it looks like a very useful feature missing from terms.

I think a work-around for the missing feature is to write a macro which, given the taxonomy name and term, returns the needed data. However, this would be something hard to maintain, b/c of the disconnect between the term definition and where the data would be stored.

Hi, i agree this is a useful feature, especially when it comes to translations of taxonomy stuff. Here is how i do it on my blog:

  • have orphan pages in some folder in content, to describe my taxonomy terms
  • get those pages in the templates, and use the page attributes to provide more “taxonomy” context

I think that would be a workaround for your usecase, do you agree?


I use lots of extra.* values on page front matter and site config alike for things like this.

A few excerpts from my site:


	name = "Miscellaneous"
	title = "Anything otherwise uncategorised"
	description = "These posts are one‐off tech‐related things that I don’t have a better categorisation for."

	name = "Rust"
	title = "The Rust programming language"
	description = "I write about Rust things routinely. Here they all are."

	name = "Fun"
	description = "Most of what I write is intended to be useful, but sometimes I write things just for fun. I make no guarantee that you will enjoy them; it is enough that <em>I</em> do."

templates/blog/tags/single.html (simplified):

<title>Blog posts tagged “{{ config.extra.taxonomies["blog/tags"][term.slug].name }}”</title>
<p>{{ config.extra.taxonomies["blog/tags"][term.slug].description }}

And one of my many macross:

{% macro render_tag(name, link=true) %}
	{%- set title = config.extra.taxonomies["blog/tags"][name].title | default(value = '') -%}
		{%- if link -%}
			a href={{ get_taxonomy_url(kind="blog/tags", name=name) }}
		{%- else -%}
		{%- endif %} class=tag
		{%- if title %} title="{{ title }}"{% endif -%}
	>{{ config.extra.taxonomies["blog/tags"][name].name }}</{% if link %}a{% else %}span{% endif %}>
{%- endmacro %}

(Meta: @keats, this site’s highlight.js needs a few languages added: rust, toml, and django, ideally with “tera” as an alias for django. I hope it’s possible to add them in this environment?)

1 Like

I’ve just added Rust, TypeScript, Django and Twig (closest to Jinja2/Tera). Toml doesn’t seem available :confused: