Converting frontmatter in GoHugo

Patrick Kollitsch  | Tuesday, November 2, 2021 at 10:49 pm
Photo by Ferenc Almasi via Unsplash
Photo by Ferenc Almasi via Unsplash

Some days ago I realised, that I keep all my configurations for GoHugo in the TOML format, while using YAML for the frontmatters in my content folder. That did not seem right ;) so I changed those too to TOML.

Hugo has an easy command convert, to transform frontmatter from one type to another.

1
2
3
hugo convert toJSON
hugo convert toTOML
hugo convert toYAML

If Hugo detects any issues, it will decide to NOT transform the frontmatter. In that case you can force it to transform by adding the --unsafe option to the call:

1
2
3
hugo convert toJSON --unsafe
hugo convert toTOML --unsafe
hugo convert toYAML --unsafe

After running this command your frontmatter will be in the new format. The only problem that I experienced was, that after converting from YAML to TOML all frontmatter items were in alphabetical order, which is nice, but might confuse us later on. I like my frontmatter sorted by topics.

Don’t forget to change your archetypes too (there is no command for this, so you need to do it manually), so all future content too is in your new preferred format.

    Remotely related

    Hyper shell
    Hyper shell
    • Patrick Kollitsch
    • Tuesday, November 16, 2021 at 7:52 pm

      Hyper Shell

      There is nothing, you can’t do with Electron, apparently. Newest proof is Hyper, a shell inside of Electron (you read that right). Developed by Vercel, the app is theme-able and extensible by plugins, like any other Electron app. It doesn’t look though like any init scripts like .

      Read Article
      stefanjudis.com
      stefanjudis.com

      You got to...

      … subscribe to Stefan Judis' Newsletter (click this link, load his site, scroll to the footer and subscribe). Trust me. It’s good. Weekly. His topics touch everything web development related and there is never an issue from which I don’t learn something new.

      Read Article