TOML Custom Tables

I have a really messed up config.toml file, the variables of which I’d love to categories through custom tables, i.e [params] etc. But I noticed that custom tables can’t be made.
So which TOML tables are supported by Hugo? I noticed that [social] is.

What did you try that didn’t work? I make heavy use of tables in my site configs… example:

  [[Params.social]]
    name = "Github"
    link = "https://github.com/kaushalmodi/"
    relme = true
  [[Params.social]]
    name = "Gitlab"
    link = "https://gitlab.com/kaushalmodi/projects"
...

Hope this helps:

https://npf.io/2014/08/intro-to-toml/

https://gohugohq.com/howto/toml-json-yaml-comparison/
1 Like

Thanks for sharing those links. Just a minor note that you just paste the links so that they are clickable i.e. don’t wrap them in ```.

Also the gohugohq is a great resource. Note though that at least one TOML example I looked in detail had a typo:

image

I’ll see if I can find a way to ping the author of that site.

2 Likes

@kaushalmodi How would you access such tables?

Your question needs to be more specific… which table? Is the table in front-matter or in site config?

The general answer is that you would refer a table like any other parameter… the only difference is that the read variable will be a map or a slice of maps or a map of slices (and so… need to get specifics on the table).

If the above fruits example is in front-matter (assuming that the typo is fixed), you can access it using .Params.fruits and then range over it… or better {{ with .Params.fruits }}.

1 Like

Sorry for the late response, I was referring to the site config.