Reserved words in Hugo?

Are there reserved words in Hugo? I have a taxonomy named resource = resources and I get this error:

GetParam("resources"): Unknown type []map[string]interface{}

Change the name in config (even to resource = resource) and I get no error.

If you have a taxonomy resource = resources, you would be expected to set that taxonomy using resources = "foo". But that would of course clash with the internal resources front-matter used for Page Resources Meta-data management… which is expected to be a map, and thus that error.

That’s what I was thinking, but wasn’t sure because they’re not bundles. So we may need to record that as a reserved word in the docs, don’t you think?

It’s already in the predefined front-matter list. You wouldn’t be able to use any of those as taxonomy.

Ah, then it’s just me not reading the docs I thought I was so familiar with :slight_smile:

And thank you. Now I have to figure out what to do with my client’s “resources”

Rename them as “assets” if it’s lots of files use sed.

Well they’ve been “resources” for about a decade now, because they are “Resources for Teachers,” and resources is their long-defined URL structure.

Can you set up redirects? From https://example.com/assets/ to https://example.com/resources/?

That will likely be my solution.

Spend them.

I would say that this isn’t something I have thought too hard about and it is very rare that we add new “Hugo fields” to the front matter. Maybe we should improve on this, but I’m not sure how.

Is not possible to put params below the params key in front matter?

And then one day someone uses param = params as taxonomy :stuck_out_tongue:

Proposal

How about having a predefined _taxonomies front-matter variable that’s a map. I intentionally propose that var to begin with _ so that we don’t have to deal with a taxonomy plural that’s actually taxonomies… and now if someone actually wants to use _taxonomies as their taxonomy plural, then good luck to them.

It can then be used in ambiguous cases like resources in this example.

The front-matter would then look like:

[_taxonomies]
  resources = ["foo"]

If someone wants to use params as their taxonomy plural, that would then work too:

[_taxonomies]
  params = ["foo"]

If the post needs to specify the Resources front-matter resources, that would work too:

[_taxonomies]
  resources = ["foo"]
[[resources]]
  src = "stay_hungry*.jpg"
  title = "Stay Hungry Stay Foolish"
  [resources.params]
     ..

About backward compatibility, these 2 will be equivalent functionally:

[_taxonomies]
  tags = ["foo"]

and

tags = ["foo"]

And… if someone wants to play with the system, and specifies tags using both methods, then the tags specified using _taxonomies will get the higher precedence.

Thoughts?

1 Like