HUGO

Should I change to TOML?

I just had a hectic week of moving from Jekyll to Hugo. I did not use any theme and only changed the Jekyll syntax to Hugo’s. My question now is if it is necessary to change the article’s front matter header from YAML to TOML? I stumbled upon TOML when doing the transfer, and it appears simpler to use than YAML so I converted my configuration file to it.

I would not bother. I think it’s very common to use TOML as config, YAML as front matter. The reasoning behind the latter is, for me at least, that GitHub understands it, and I also suspect tooling in general will be better.

1 Like

This is reassuring.

Aside from personal preference, the only time I find TOML front matter to be advantageous is when working with custom date fields. For example, if I have an event content type with event_start and event_stop dates.

Example:
https://gohugo.io/templates/introduction/#example-show-future-events

If you restrict front matter to the TOML format, and omit quotation marks surrounding date fields, you can perform date comparisons without casting.

With TOML, unquoted dates are first-class citizens. With YAML/JSON, dates are strings.

3 Likes

@jmooring I only write blog posts for now. I will put what you wrote in mind if I ever reach a point where I need custom data for my site. Regards. :grinning_face_with_smiling_eyes:

2 Likes

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